import jaggl.OpenGL;

public class Class141_Sub6 extends Class141 {

   static final String aString9918 = "varying vec3 wvVertex;\nvarying float waterDepth;\nuniform vec3 sunDir;\nuniform vec4 sunColour;\nuniform float sunExponent;\nuniform vec2 waveIntensity;\nuniform float waveExponent;\nuniform float breakWaterDepth;\nuniform float breakWaterOffset;\nuniform sampler3D normalSampler;\nuniform samplerCube envMapSampler;\nvoid main() {\nvec4 wnNormal = texture3D(normalSampler, gl_TexCoord[0].xyz).rbga;\nwnNormal.xyz = 2.0*wnNormal.xyz-1.0;\nvec3 wnVector = normalize(wvVertex);\nvec3 wnReflection = reflect(wnVector, wnNormal.xyz);\nvec3 envColour = textureCube(envMapSampler, wnReflection).rgb;\nvec4 specularColour = sunColour*pow(clamp(-dot(sunDir, wnReflection), 0.0, 1.0), sunExponent);\nfloat shoreFactor = clamp(waterDepth/breakWaterDepth-breakWaterOffset*wnNormal.w, 0.0, 1.0);\nfloat waveFactor = pow(1.0-shoreFactor, waveExponent)-0.5;\nwaveFactor = -4.0*waveFactor*waveFactor+1.0;\nfloat ndote = dot(wnVector, wnNormal.xyz);\nfloat fresnel = pow(1.0-abs(ndote), 1.0);\nvec4 surfaceColour = mix(vec4(envColour, fresnel*shoreFactor), (waveIntensity.x*wnNormal.wwww)+waveIntensity.y, waveFactor)+specularColour*shoreFactor;\ngl_FragColor = vec4(mix(surfaceColour.rgb, gl_Fog.color.rgb, gl_FogFragCoord), surfaceColour.a);\n}\n";
   boolean aBool9919 = false;
   boolean aBool9920 = false;
   static final String aString9921 = "uniform float time;\nuniform float scale;\nvarying vec3 wvVertex;\nvarying float waterDepth;\nvoid main() {\nwaterDepth = gl_MultiTexCoord0.z;\nvec4 ecVertex = gl_ModelViewMatrix*gl_Vertex;\nwvVertex.x = dot(gl_NormalMatrix[0], ecVertex.xyz);\nwvVertex.y = dot(gl_NormalMatrix[1], ecVertex.xyz);\nwvVertex.z = dot(gl_NormalMatrix[2], ecVertex.xyz);\ngl_TexCoord[0].x = dot(gl_TextureMatrix[0][0], gl_MultiTexCoord0)*scale;\ngl_TexCoord[0].y = dot(gl_TextureMatrix[0][1], gl_MultiTexCoord0)*scale;\ngl_TexCoord[0].z = time;\ngl_TexCoord[0].w = 1.0;\ngl_FogFragCoord = clamp((ecVertex.z-gl_Fog.start)*gl_Fog.scale, 0.0, 1.0);\ngl_Position = ftransform();\n}\n";
   Class137 aClass137_9922;
   Class135 aClass135_9923;


   void method2634(int var1, int var2) {
      if(this.aBool9920) {
         int var3 = 1 << (var1 & 3);
         float var4 = (float)(1 << (var1 >> 3 & 7)) / 32.0F;
         int var5 = var2 & '\uffff';
         float var6 = (float)(var2 >> 16 & 3) / 8.0F;
         float var7 = (float)(var2 >> 19 & 15) / 16.0F;
         float var8 = (float)(var2 >> 23 & 15) / 16.0F;
         int var9 = var2 >> 27 & 15;
         int var10 = this.aClass137_9922.anInt1606;
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "time"), (float)(var3 * this.aClass545_Sub1_1628.anInt9158 % '\u9c40') / 40000.0F);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "scale"), var4);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "breakWaterDepth"), (float)var5);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "breakWaterOffset"), var6);
         OpenGL.glUniform2f(OpenGL.glGetUniformLocation(var10, "waveIntensity"), var8, var7);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "waveExponent"), (float)var9);
      }

   }

   boolean method2633() {
      return this.aBool9919;
   }

   void method2630() {
      if(this.aBool9920) {
         this.aClass545_Sub1_1628.method14641(1);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         this.aClass545_Sub1_1628.method14641(0);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         OpenGL.glUseProgram(0);
         this.aBool9920 = false;
      }

   }

   void method2636(boolean var1) {}

   void method2631(boolean var1) {
      Class147_Sub1 var2 = this.aClass545_Sub1_1628.method14579();
      if(this.aBool9919 && var2 != null) {
         float var3 = 1.0F + (1.0F - Math.abs(this.aClass545_Sub1_1628.aFloatArray9265[1])) * 2.0F;
         this.aClass545_Sub1_1628.method14641(1);
         this.aClass545_Sub1_1628.method14725(var2);
         this.aClass545_Sub1_1628.method14641(0);
         this.aClass545_Sub1_1628.method14725(this.aClass135_9923.aClass147_Sub2_1588);
         int var4 = this.aClass137_9922.anInt1606;
         OpenGL.glUseProgram(var4);
         OpenGL.glUniform1i(OpenGL.glGetUniformLocation(var4, "normalSampler"), 0);
         OpenGL.glUniform1i(OpenGL.glGetUniformLocation(var4, "envMapSampler"), 1);
         OpenGL.glUniform3f(OpenGL.glGetUniformLocation(var4, "sunDir"), -this.aClass545_Sub1_1628.aFloatArray9265[0], -this.aClass545_Sub1_1628.aFloatArray9265[1], -this.aClass545_Sub1_1628.aFloatArray9265[2]);
         OpenGL.glUniform4f(OpenGL.glGetUniformLocation(var4, "sunColour"), this.aClass545_Sub1_1628.aFloat9130 * var3, this.aClass545_Sub1_1628.aFloat9123 * var3, this.aClass545_Sub1_1628.aFloat9225 * var3, 1.0F);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var4, "sunExponent"), 64.0F + Math.abs(this.aClass545_Sub1_1628.aFloatArray9265[1]) * 928.0F);
         this.aBool9920 = true;
      }

   }

   void method2628(Class147 var1, int var2) {
      if(!this.aBool9920) {
         this.aClass545_Sub1_1628.method14725(var1);
         this.aClass545_Sub1_1628.method14591(var2);
      }

   }

   void method2625(boolean var1) {
      Class147_Sub1 var2 = this.aClass545_Sub1_1628.method14579();
      if(this.aBool9919 && var2 != null) {
         float var3 = 1.0F + (1.0F - Math.abs(this.aClass545_Sub1_1628.aFloatArray9265[1])) * 2.0F;
         this.aClass545_Sub1_1628.method14641(1);
         this.aClass545_Sub1_1628.method14725(var2);
         this.aClass545_Sub1_1628.method14641(0);
         this.aClass545_Sub1_1628.method14725(this.aClass135_9923.aClass147_Sub2_1588);
         int var4 = this.aClass137_9922.anInt1606;
         OpenGL.glUseProgram(var4);
         OpenGL.glUniform1i(OpenGL.glGetUniformLocation(var4, "normalSampler"), 0);
         OpenGL.glUniform1i(OpenGL.glGetUniformLocation(var4, "envMapSampler"), 1);
         OpenGL.glUniform3f(OpenGL.glGetUniformLocation(var4, "sunDir"), -this.aClass545_Sub1_1628.aFloatArray9265[0], -this.aClass545_Sub1_1628.aFloatArray9265[1], -this.aClass545_Sub1_1628.aFloatArray9265[2]);
         OpenGL.glUniform4f(OpenGL.glGetUniformLocation(var4, "sunColour"), this.aClass545_Sub1_1628.aFloat9130 * var3, this.aClass545_Sub1_1628.aFloat9123 * var3, this.aClass545_Sub1_1628.aFloat9225 * var3, 1.0F);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var4, "sunExponent"), 64.0F + Math.abs(this.aClass545_Sub1_1628.aFloatArray9265[1]) * 928.0F);
         this.aBool9920 = true;
      }

   }

   boolean method2629() {
      return this.aBool9919;
   }

   boolean method2626() {
      return this.aBool9919;
   }

   Class141_Sub6(Class545_Sub1 var1, Class135 var2) {
      super(var1);
      this.aClass135_9923 = var2;
      if(this.aClass135_9923.aClass147_Sub2_1588 != null && this.aClass545_Sub1_1628.aBool9170 && this.aClass545_Sub1_1628.aBool9281) {
         Class130 var3 = Class130.method2490(this.aClass545_Sub1_1628, '\u8b31', "uniform float time;\nuniform float scale;\nvarying vec3 wvVertex;\nvarying float waterDepth;\nvoid main() {\nwaterDepth = gl_MultiTexCoord0.z;\nvec4 ecVertex = gl_ModelViewMatrix*gl_Vertex;\nwvVertex.x = dot(gl_NormalMatrix[0], ecVertex.xyz);\nwvVertex.y = dot(gl_NormalMatrix[1], ecVertex.xyz);\nwvVertex.z = dot(gl_NormalMatrix[2], ecVertex.xyz);\ngl_TexCoord[0].x = dot(gl_TextureMatrix[0][0], gl_MultiTexCoord0)*scale;\ngl_TexCoord[0].y = dot(gl_TextureMatrix[0][1], gl_MultiTexCoord0)*scale;\ngl_TexCoord[0].z = time;\ngl_TexCoord[0].w = 1.0;\ngl_FogFragCoord = clamp((ecVertex.z-gl_Fog.start)*gl_Fog.scale, 0.0, 1.0);\ngl_Position = ftransform();\n}\n");
         Class130 var4 = Class130.method2490(this.aClass545_Sub1_1628, '\u8b30', "varying vec3 wvVertex;\nvarying float waterDepth;\nuniform vec3 sunDir;\nuniform vec4 sunColour;\nuniform float sunExponent;\nuniform vec2 waveIntensity;\nuniform float waveExponent;\nuniform float breakWaterDepth;\nuniform float breakWaterOffset;\nuniform sampler3D normalSampler;\nuniform samplerCube envMapSampler;\nvoid main() {\nvec4 wnNormal = texture3D(normalSampler, gl_TexCoord[0].xyz).rbga;\nwnNormal.xyz = 2.0*wnNormal.xyz-1.0;\nvec3 wnVector = normalize(wvVertex);\nvec3 wnReflection = reflect(wnVector, wnNormal.xyz);\nvec3 envColour = textureCube(envMapSampler, wnReflection).rgb;\nvec4 specularColour = sunColour*pow(clamp(-dot(sunDir, wnReflection), 0.0, 1.0), sunExponent);\nfloat shoreFactor = clamp(waterDepth/breakWaterDepth-breakWaterOffset*wnNormal.w, 0.0, 1.0);\nfloat waveFactor = pow(1.0-shoreFactor, waveExponent)-0.5;\nwaveFactor = -4.0*waveFactor*waveFactor+1.0;\nfloat ndote = dot(wnVector, wnNormal.xyz);\nfloat fresnel = pow(1.0-abs(ndote), 1.0);\nvec4 surfaceColour = mix(vec4(envColour, fresnel*shoreFactor), (waveIntensity.x*wnNormal.wwww)+waveIntensity.y, waveFactor)+specularColour*shoreFactor;\ngl_FragColor = vec4(mix(surfaceColour.rgb, gl_Fog.color.rgb, gl_FogFragCoord), surfaceColour.a);\n}\n");
         this.aClass137_9922 = Class137.method2619(this.aClass545_Sub1_1628, new Class130[]{var3, var4});
         this.aBool9919 = this.aClass137_9922 != null;
      }

   }

   void method2632() {
      if(this.aBool9920) {
         this.aClass545_Sub1_1628.method14641(1);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         this.aClass545_Sub1_1628.method14641(0);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         OpenGL.glUseProgram(0);
         this.aBool9920 = false;
      }

   }

   void method2627(int var1, int var2) {
      if(this.aBool9920) {
         int var3 = 1 << (var1 & 3);
         float var4 = (float)(1 << (var1 >> 3 & 7)) / 32.0F;
         int var5 = var2 & '\uffff';
         float var6 = (float)(var2 >> 16 & 3) / 8.0F;
         float var7 = (float)(var2 >> 19 & 15) / 16.0F;
         float var8 = (float)(var2 >> 23 & 15) / 16.0F;
         int var9 = var2 >> 27 & 15;
         int var10 = this.aClass137_9922.anInt1606;
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "time"), (float)(var3 * this.aClass545_Sub1_1628.anInt9158 % '\u9c40') / 40000.0F);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "scale"), var4);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "breakWaterDepth"), (float)var5);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "breakWaterOffset"), var6);
         OpenGL.glUniform2f(OpenGL.glGetUniformLocation(var10, "waveIntensity"), var8, var7);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "waveExponent"), (float)var9);
      }

   }

   void method2635(Class147 var1, int var2) {
      if(!this.aBool9920) {
         this.aClass545_Sub1_1628.method14725(var1);
         this.aClass545_Sub1_1628.method14591(var2);
      }

   }

   void method2639(int var1, int var2) {
      if(this.aBool9920) {
         int var3 = 1 << (var1 & 3);
         float var4 = (float)(1 << (var1 >> 3 & 7)) / 32.0F;
         int var5 = var2 & '\uffff';
         float var6 = (float)(var2 >> 16 & 3) / 8.0F;
         float var7 = (float)(var2 >> 19 & 15) / 16.0F;
         float var8 = (float)(var2 >> 23 & 15) / 16.0F;
         int var9 = var2 >> 27 & 15;
         int var10 = this.aClass137_9922.anInt1606;
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "time"), (float)(var3 * this.aClass545_Sub1_1628.anInt9158 % '\u9c40') / 40000.0F);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "scale"), var4);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "breakWaterDepth"), (float)var5);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "breakWaterOffset"), var6);
         OpenGL.glUniform2f(OpenGL.glGetUniformLocation(var10, "waveIntensity"), var8, var7);
         OpenGL.glUniform1f(OpenGL.glGetUniformLocation(var10, "waveExponent"), (float)var9);
      }

   }

   void method2623() {
      if(this.aBool9920) {
         this.aClass545_Sub1_1628.method14641(1);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         this.aClass545_Sub1_1628.method14641(0);
         this.aClass545_Sub1_1628.method14725((Class147)null);
         OpenGL.glUseProgram(0);
         this.aBool9920 = false;
      }

   }

   void method2637(boolean var1) {}

   void method2638(boolean var1) {}

   void method2624(boolean var1) {}
}
