import jaggl.OpenGL;

public class Class163 {

   Class137 aClass137_2005;
   Class545_Sub1 aClass545_Sub1_2006;
   static final String aString2007 = "uniform float rcpRelief;\nuniform vec2 sampleSize;\nuniform sampler3D heightMap;\nvoid main() {\nfloat dx = texture3D(heightMap, vec3(-sampleSize.x, 0.0, 0.0)+gl_TexCoord[0].xyz).r - texture3D(heightMap, vec3(sampleSize.x, 0.0, 0.0)+gl_TexCoord[0].xyz).r;\nfloat dy = texture3D(heightMap, vec3(0.0, -sampleSize.y, 0.0)+gl_TexCoord[0].xyz).r - texture3D(heightMap, vec3(0.0, sampleSize.y, 0.0)+gl_TexCoord[0].xyz).r;\ngl_FragColor = vec4(0.5+normalize(vec3(dx, dy, rcpRelief))*0.5, texture3D(heightMap, gl_TexCoord[0].xyz).r);\n}\n";


   boolean method2832(Class147_Sub2 var1, Class147_Sub2 var2, float var3) {
      if(!this.method2833()) {
         return false;
      } else {
         Class151_Sub1_Sub2 var4 = this.aClass545_Sub1_2006.aClass151_Sub1_Sub2_9288;
         Class225_Sub14_Sub18 var5 = new Class225_Sub14_Sub18(this.aClass545_Sub1_2006, Class98.aClass98_992, Class91.aClass91_897, var1.anInt9897, var1.anInt9896);
         boolean var6 = false;
         this.aClass545_Sub1_2006.method11451(var4, -543666943);
         var4.method14460(0, var5);
         if(var4.method14461()) {
            OpenGL.glPushMatrix();
            OpenGL.glLoadIdentity();
            OpenGL.glMatrixMode(5889);
            OpenGL.glPushMatrix();
            OpenGL.glLoadIdentity();
            OpenGL.glOrtho(0.0D, 1.0D, 0.0D, 1.0D, -1.0D, 1.0D);
            OpenGL.glPushAttrib(2048);
            OpenGL.glViewport(0, 0, var1.anInt9897, var1.anInt9896);
            OpenGL.glUseProgram(this.aClass137_2005.anInt1606);
            OpenGL.glUniform1i(OpenGL.glGetUniformLocation(this.aClass137_2005.anInt1606, "heightMap"), 0);
            OpenGL.glUniform1f(OpenGL.glGetUniformLocation(this.aClass137_2005.anInt1606, "rcpRelief"), 1.0F / var3);
            OpenGL.glUniform2f(OpenGL.glGetUniformLocation(this.aClass137_2005.anInt1606, "sampleSize"), 1.0F / (float)var2.anInt9897, 1.0F / (float)var2.anInt9896);

            for(int var7 = 0; var7 < var1.anInt9895; ++var7) {
               float var8 = (float)var7 / (float)var1.anInt9895;
               this.aClass545_Sub1_2006.method14725(var2);
               OpenGL.glBegin(7);
               OpenGL.glTexCoord3f(0.0F, 0.0F, var8);
               OpenGL.glVertex2f(0.0F, 0.0F);
               OpenGL.glTexCoord3f(1.0F, 0.0F, var8);
               OpenGL.glVertex2f(1.0F, 0.0F);
               OpenGL.glTexCoord3f(1.0F, 1.0F, var8);
               OpenGL.glVertex2f(1.0F, 1.0F);
               OpenGL.glTexCoord3f(0.0F, 1.0F, var8);
               OpenGL.glVertex2f(0.0F, 1.0F);
               OpenGL.glEnd();
               var1.method15431(0, 0, var7, var1.anInt9897, var1.anInt9896, 0, 0);
            }

            OpenGL.glUseProgram(0);
            OpenGL.glPopAttrib();
            OpenGL.glPopMatrix();
            OpenGL.glMatrixMode(5888);
            OpenGL.glPopMatrix();
            var6 = true;
         }

         var4.method14460(0, (Interface7)null);
         this.aClass545_Sub1_2006.method11672(var4, (byte)20);
         return var6;
      }
   }

   boolean method2833() {
      if(this.aClass545_Sub1_2006.aBool9266 && this.aClass545_Sub1_2006.aBool9281 && this.aClass137_2005 == null) {
         Class130 var1 = Class130.method2490(this.aClass545_Sub1_2006, '\u8b30', "uniform float rcpRelief;\nuniform vec2 sampleSize;\nuniform sampler3D heightMap;\nvoid main() {\nfloat dx = texture3D(heightMap, vec3(-sampleSize.x, 0.0, 0.0)+gl_TexCoord[0].xyz).r - texture3D(heightMap, vec3(sampleSize.x, 0.0, 0.0)+gl_TexCoord[0].xyz).r;\nfloat dy = texture3D(heightMap, vec3(0.0, -sampleSize.y, 0.0)+gl_TexCoord[0].xyz).r - texture3D(heightMap, vec3(0.0, sampleSize.y, 0.0)+gl_TexCoord[0].xyz).r;\ngl_FragColor = vec4(0.5+normalize(vec3(dx, dy, rcpRelief))*0.5, texture3D(heightMap, gl_TexCoord[0].xyz).r);\n}\n");
         if(var1 != null) {
            this.aClass137_2005 = Class137.method2619(this.aClass545_Sub1_2006, new Class130[]{var1});
         }
      }

      return this.aClass137_2005 != null;
   }

   Class163(Class545_Sub1 var1) {
      this.aClass545_Sub1_2006 = var1;
   }

   boolean method2834() {
      if(this.aClass545_Sub1_2006.aBool9266 && this.aClass545_Sub1_2006.aBool9281 && this.aClass137_2005 == null) {
         Class130 var1 = Class130.method2490(this.aClass545_Sub1_2006, '\u8b30', "uniform float rcpRelief;\nuniform vec2 sampleSize;\nuniform sampler3D heightMap;\nvoid main() {\nfloat dx = texture3D(heightMap, vec3(-sampleSize.x, 0.0, 0.0)+gl_TexCoord[0].xyz).r - texture3D(heightMap, vec3(sampleSize.x, 0.0, 0.0)+gl_TexCoord[0].xyz).r;\nfloat dy = texture3D(heightMap, vec3(0.0, -sampleSize.y, 0.0)+gl_TexCoord[0].xyz).r - texture3D(heightMap, vec3(0.0, sampleSize.y, 0.0)+gl_TexCoord[0].xyz).r;\ngl_FragColor = vec4(0.5+normalize(vec3(dx, dy, rcpRelief))*0.5, texture3D(heightMap, gl_TexCoord[0].xyz).r);\n}\n");
         if(var1 != null) {
            this.aClass137_2005 = Class137.method2619(this.aClass545_Sub1_2006, new Class130[]{var1});
         }
      }

      return this.aClass137_2005 != null;
   }

   boolean method2835(Class147_Sub2 var1, Class147_Sub2 var2, float var3) {
      if(!this.method2833()) {
         return false;
      } else {
         Class151_Sub1_Sub2 var4 = this.aClass545_Sub1_2006.aClass151_Sub1_Sub2_9288;
         Class225_Sub14_Sub18 var5 = new Class225_Sub14_Sub18(this.aClass545_Sub1_2006, Class98.aClass98_992, Class91.aClass91_897, var1.anInt9897, var1.anInt9896);
         boolean var6 = false;
         this.aClass545_Sub1_2006.method11451(var4, -543666943);
         var4.method14460(0, var5);
         if(var4.method14461()) {
            OpenGL.glPushMatrix();
            OpenGL.glLoadIdentity();
            OpenGL.glMatrixMode(5889);
            OpenGL.glPushMatrix();
            OpenGL.glLoadIdentity();
            OpenGL.glOrtho(0.0D, 1.0D, 0.0D, 1.0D, -1.0D, 1.0D);
            OpenGL.glPushAttrib(2048);
            OpenGL.glViewport(0, 0, var1.anInt9897, var1.anInt9896);
            OpenGL.glUseProgram(this.aClass137_2005.anInt1606);
            OpenGL.glUniform1i(OpenGL.glGetUniformLocation(this.aClass137_2005.anInt1606, "heightMap"), 0);
            OpenGL.glUniform1f(OpenGL.glGetUniformLocation(this.aClass137_2005.anInt1606, "rcpRelief"), 1.0F / var3);
            OpenGL.glUniform2f(OpenGL.glGetUniformLocation(this.aClass137_2005.anInt1606, "sampleSize"), 1.0F / (float)var2.anInt9897, 1.0F / (float)var2.anInt9896);

            for(int var7 = 0; var7 < var1.anInt9895; ++var7) {
               float var8 = (float)var7 / (float)var1.anInt9895;
               this.aClass545_Sub1_2006.method14725(var2);
               OpenGL.glBegin(7);
               OpenGL.glTexCoord3f(0.0F, 0.0F, var8);
               OpenGL.glVertex2f(0.0F, 0.0F);
               OpenGL.glTexCoord3f(1.0F, 0.0F, var8);
               OpenGL.glVertex2f(1.0F, 0.0F);
               OpenGL.glTexCoord3f(1.0F, 1.0F, var8);
               OpenGL.glVertex2f(1.0F, 1.0F);
               OpenGL.glTexCoord3f(0.0F, 1.0F, var8);
               OpenGL.glVertex2f(0.0F, 1.0F);
               OpenGL.glEnd();
               var1.method15431(0, 0, var7, var1.anInt9897, var1.anInt9896, 0, 0);
            }

            OpenGL.glUseProgram(0);
            OpenGL.glPopAttrib();
            OpenGL.glPopMatrix();
            OpenGL.glMatrixMode(5888);
            OpenGL.glPopMatrix();
            var6 = true;
         }

         var4.method14460(0, (Interface7)null);
         this.aClass545_Sub1_2006.method11672(var4, (byte)107);
         return var6;
      }
   }
}
