/* Class108_Sub5 - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
import jaggl.OpenGL;

public class Class108_Sub5 extends Class108
{
    static final String aString8696
	= "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";
    static final String aString8697
	= "varying vec3 wvVertex;\nvarying float waterDepth;\nuniform vec3 sunDir;\nuniform vec4 sunColour;\nuniform float sunExponent;\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 ndote = dot(wnVector, wnNormal.xyz);\nfloat fresnel = pow(1.0-abs(ndote), 2.0);\nvec4 surfaceColour = vec4(envColour, fresnel*shoreFactor)+specularColour*shoreFactor;\ngl_FragColor = vec4(mix(surfaceColour.rgb, gl_Fog.color.rgb, gl_FogFragCoord), surfaceColour.a);\n}\n";
    Class90 aClass90_8698;
    boolean aBool8699 = false;
    Class99 aClass99_8700;
    boolean aBool8701 = false;
    
    void method1452(int i, int i_0_) {
	if (((Class108_Sub5) this).aBool8699) {
	    int i_1_ = 1 << (i & 0x3);
	    float f = (float) (1 << (i >> 3 & 0x7)) / 32.0F;
	    int i_2_ = i_0_ & 0xffff;
	    float f_3_ = (float) (i_0_ >> 16 & 0x3) / 8.0F;
	    int i_4_
		= ((Class90) ((Class108_Sub5) this).aClass90_8698).anInt1234;
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_4_, "time"),
			       (float) (i_1_
					* ((Class151_Sub3)
					   (((Class108_Sub5) this)
					    .aClass151_Sub3_1429)).anInt9253
					% 40000) / 40000.0F);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_4_, "scale"), f);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_4_,
							   "breakWaterDepth"),
			       (float) i_2_);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_4_,
							   "breakWaterOffset"),
			       f_3_);
	}
    }
    
    Class108_Sub5(Class151_Sub3 class151_sub3, Class99 class99) {
	super(class151_sub3);
	((Class108_Sub5) this).aClass99_8700 = class99;
	if ((((Class99) ((Class108_Sub5) this).aClass99_8700)
	     .aClass100_Sub4_1326) != null
	    && (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		.aBool9379)
	    && (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		.aBool9381)) {
	    Class102 class102
		= (Class102.method1407
		   (((Class108_Sub5) this).aClass151_Sub3_1429, 35633,
		    "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"));
	    Class102 class102_5_
		= (Class102.method1407
		   (((Class108_Sub5) this).aClass151_Sub3_1429, 35632,
		    "varying vec3 wvVertex;\nvarying float waterDepth;\nuniform vec3 sunDir;\nuniform vec4 sunColour;\nuniform float sunExponent;\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 ndote = dot(wnVector, wnNormal.xyz);\nfloat fresnel = pow(1.0-abs(ndote), 2.0);\nvec4 surfaceColour = vec4(envColour, fresnel*shoreFactor)+specularColour*shoreFactor;\ngl_FragColor = vec4(mix(surfaceColour.rgb, gl_Fog.color.rgb, gl_FogFragCoord), surfaceColour.a);\n}\n"));
	    ((Class108_Sub5) this).aClass90_8698
		= Class90.method1246((((Class108_Sub5) this)
				      .aClass151_Sub3_1429),
				     new Class102[] { class102, class102_5_ });
	    ((Class108_Sub5) this).aBool8701
		= ((Class108_Sub5) this).aClass90_8698 != null;
	}
    }
    
    boolean method1449() {
	return ((Class108_Sub5) this).aBool8701;
    }
    
    void method1470(Class100 class100, int i) {
	if (!((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(class100);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8592(i);
	}
    }
    
    void method1451() {
	if (((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(1);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(0);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    OpenGL.glUseProgram(0);
	    ((Class108_Sub5) this).aBool8699 = false;
	}
    }
    
    void method1448(Class100 class100, int i) {
	if (!((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(class100);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8592(i);
	}
    }
    
    void method1464(boolean bool) {
	/* empty */
    }
    
    boolean method1454() {
	return ((Class108_Sub5) this).aBool8701;
    }
    
    boolean method1455() {
	return ((Class108_Sub5) this).aBool8701;
    }
    
    void method1457(boolean bool) {
	Class100_Sub2 class100_sub2
	    = ((Class108_Sub5) this).aClass151_Sub3_1429.method8669();
	if (((Class108_Sub5) this).aBool8701 && class100_sub2 != null) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(1);
	    ((Class108_Sub5) this).aClass151_Sub3_1429
		.method8591(class100_sub2);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(0);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591
		(((Class99) ((Class108_Sub5) this).aClass99_8700)
		 .aClass100_Sub4_1326);
	    int i = ((Class90) ((Class108_Sub5) this).aClass90_8698).anInt1234;
	    OpenGL.glUseProgram(i);
	    OpenGL.glUniform1i(OpenGL.glGetUniformLocation(i, "normalSampler"),
			       0);
	    OpenGL.glUniform1i(OpenGL.glGetUniformLocation(i, "envMapSampler"),
			       1);
	    OpenGL.glUniform3f
		(OpenGL.glGetUniformLocation(i, "sunDir"),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[0]),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[1]),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[2]));
	    OpenGL.glUniform4f
		(OpenGL.glGetUniformLocation(i, "sunColour"),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9322),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9249),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9272),
		 1.0F);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i, "sunExponent"),
			       96.0F + Math.abs(((Class151_Sub3)
						 (((Class108_Sub5) this)
						  .aClass151_Sub3_1429))
						.aFloatArray9323[1]) * 928.0F);
	    ((Class108_Sub5) this).aBool8699 = true;
	}
    }
    
    void method1469(boolean bool) {
	Class100_Sub2 class100_sub2
	    = ((Class108_Sub5) this).aClass151_Sub3_1429.method8669();
	if (((Class108_Sub5) this).aBool8701 && class100_sub2 != null) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(1);
	    ((Class108_Sub5) this).aClass151_Sub3_1429
		.method8591(class100_sub2);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(0);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591
		(((Class99) ((Class108_Sub5) this).aClass99_8700)
		 .aClass100_Sub4_1326);
	    int i = ((Class90) ((Class108_Sub5) this).aClass90_8698).anInt1234;
	    OpenGL.glUseProgram(i);
	    OpenGL.glUniform1i(OpenGL.glGetUniformLocation(i, "normalSampler"),
			       0);
	    OpenGL.glUniform1i(OpenGL.glGetUniformLocation(i, "envMapSampler"),
			       1);
	    OpenGL.glUniform3f
		(OpenGL.glGetUniformLocation(i, "sunDir"),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[0]),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[1]),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[2]));
	    OpenGL.glUniform4f
		(OpenGL.glGetUniformLocation(i, "sunColour"),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9322),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9249),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9272),
		 1.0F);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i, "sunExponent"),
			       96.0F + Math.abs(((Class151_Sub3)
						 (((Class108_Sub5) this)
						  .aClass151_Sub3_1429))
						.aFloatArray9323[1]) * 928.0F);
	    ((Class108_Sub5) this).aBool8699 = true;
	}
    }
    
    void method1461() {
	if (((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(1);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(0);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    OpenGL.glUseProgram(0);
	    ((Class108_Sub5) this).aBool8699 = false;
	}
    }
    
    void method1467(boolean bool) {
	/* empty */
    }
    
    void method1460(boolean bool) {
	/* empty */
    }
    
    void method1450(boolean bool) {
	Class100_Sub2 class100_sub2
	    = ((Class108_Sub5) this).aClass151_Sub3_1429.method8669();
	if (((Class108_Sub5) this).aBool8701 && class100_sub2 != null) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(1);
	    ((Class108_Sub5) this).aClass151_Sub3_1429
		.method8591(class100_sub2);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(0);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591
		(((Class99) ((Class108_Sub5) this).aClass99_8700)
		 .aClass100_Sub4_1326);
	    int i = ((Class90) ((Class108_Sub5) this).aClass90_8698).anInt1234;
	    OpenGL.glUseProgram(i);
	    OpenGL.glUniform1i(OpenGL.glGetUniformLocation(i, "normalSampler"),
			       0);
	    OpenGL.glUniform1i(OpenGL.glGetUniformLocation(i, "envMapSampler"),
			       1);
	    OpenGL.glUniform3f
		(OpenGL.glGetUniformLocation(i, "sunDir"),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[0]),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[1]),
		 -(((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		   .aFloatArray9323[2]));
	    OpenGL.glUniform4f
		(OpenGL.glGetUniformLocation(i, "sunColour"),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9322),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9249),
		 (((Class151_Sub3) ((Class108_Sub5) this).aClass151_Sub3_1429)
		  .aFloat9272),
		 1.0F);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i, "sunExponent"),
			       96.0F + Math.abs(((Class151_Sub3)
						 (((Class108_Sub5) this)
						  .aClass151_Sub3_1429))
						.aFloatArray9323[1]) * 928.0F);
	    ((Class108_Sub5) this).aBool8699 = true;
	}
    }
    
    void method1462() {
	if (((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(1);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(0);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    OpenGL.glUseProgram(0);
	    ((Class108_Sub5) this).aBool8699 = false;
	}
    }
    
    void method1463() {
	if (((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(1);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(0);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    OpenGL.glUseProgram(0);
	    ((Class108_Sub5) this).aBool8699 = false;
	}
    }
    
    void method1459() {
	if (((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(1);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8590(0);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(null);
	    OpenGL.glUseProgram(0);
	    ((Class108_Sub5) this).aBool8699 = false;
	}
    }
    
    void method1465(int i, int i_6_) {
	if (((Class108_Sub5) this).aBool8699) {
	    int i_7_ = 1 << (i & 0x3);
	    float f = (float) (1 << (i >> 3 & 0x7)) / 32.0F;
	    int i_8_ = i_6_ & 0xffff;
	    float f_9_ = (float) (i_6_ >> 16 & 0x3) / 8.0F;
	    int i_10_
		= ((Class90) ((Class108_Sub5) this).aClass90_8698).anInt1234;
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_10_, "time"),
			       (float) (i_7_
					* ((Class151_Sub3)
					   (((Class108_Sub5) this)
					    .aClass151_Sub3_1429)).anInt9253
					% 40000) / 40000.0F);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_10_, "scale"), f);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_10_,
							   "breakWaterDepth"),
			       (float) i_8_);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_10_,
							   "breakWaterOffset"),
			       f_9_);
	}
    }
    
    void method1466(int i, int i_11_) {
	if (((Class108_Sub5) this).aBool8699) {
	    int i_12_ = 1 << (i & 0x3);
	    float f = (float) (1 << (i >> 3 & 0x7)) / 32.0F;
	    int i_13_ = i_11_ & 0xffff;
	    float f_14_ = (float) (i_11_ >> 16 & 0x3) / 8.0F;
	    int i_15_
		= ((Class90) ((Class108_Sub5) this).aClass90_8698).anInt1234;
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_15_, "time"),
			       (float) (i_12_
					* ((Class151_Sub3)
					   (((Class108_Sub5) this)
					    .aClass151_Sub3_1429)).anInt9253
					% 40000) / 40000.0F);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_15_, "scale"), f);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_15_,
							   "breakWaterDepth"),
			       (float) i_13_);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_15_,
							   "breakWaterOffset"),
			       f_14_);
	}
    }
    
    void method1458(int i, int i_16_) {
	if (((Class108_Sub5) this).aBool8699) {
	    int i_17_ = 1 << (i & 0x3);
	    float f = (float) (1 << (i >> 3 & 0x7)) / 32.0F;
	    int i_18_ = i_16_ & 0xffff;
	    float f_19_ = (float) (i_16_ >> 16 & 0x3) / 8.0F;
	    int i_20_
		= ((Class90) ((Class108_Sub5) this).aClass90_8698).anInt1234;
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_20_, "time"),
			       (float) (i_17_
					* ((Class151_Sub3)
					   (((Class108_Sub5) this)
					    .aClass151_Sub3_1429)).anInt9253
					% 40000) / 40000.0F);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_20_, "scale"), f);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_20_,
							   "breakWaterDepth"),
			       (float) i_18_);
	    OpenGL.glUniform1f(OpenGL.glGetUniformLocation(i_20_,
							   "breakWaterOffset"),
			       f_19_);
	}
    }
    
    void method1468(Class100 class100, int i) {
	if (!((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(class100);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8592(i);
	}
    }
    
    void method1456(Class100 class100, int i) {
	if (!((Class108_Sub5) this).aBool8699) {
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8591(class100);
	    ((Class108_Sub5) this).aClass151_Sub3_1429.method8592(i);
	}
    }
    
    void method1453(boolean bool) {
	/* empty */
    }
}
