Pārlūkot izejas kodu

Fixed shader warnings.

Mr.doob 10 gadi atpakaļ
vecāks
revīzija
09e32d6ade
2 mainītis faili ar 11 papildinājumiem un 17 dzēšanām
  1. 3 4
      examples/js/SkyShader.js
  2. 8 13
      examples/js/shaders/SSAOShader.js

+ 3 - 4
examples/js/SkyShader.js

@@ -62,9 +62,6 @@ THREE.ShaderLib[ 'sky' ] = {
 		"uniform float mieCoefficient;",
 		"uniform float mieDirectionalG;",
 
-		"vec3 sunDirection = normalize(sunPosition);",
-		"float reileighCoefficient = reileigh;",
-
 		"// constants for atmospheric scattering",
 		"const float e = 2.71828182845904523536028747135266249775724709369995957;",
 		"const float pi = 3.141592653589793238462643383279502884197169;",
@@ -160,7 +157,9 @@ THREE.ShaderLib[ 'sky' ] = {
 
 			 "// gl_FragColor = vec4(sunfade, sunfade, sunfade, 1.0);",
 
-			"reileighCoefficient = reileighCoefficient - (1.0* (1.0-sunfade));",
+			"float reileighCoefficient = reileigh - (1.0* (1.0-sunfade));",
+
+			"vec3 sunDirection = normalize(sunPosition);",
 
 			"float sunE = sunIntensity(dot(sunDirection, up));",
 

+ 8 - 13
examples/js/shaders/SSAOShader.js

@@ -61,15 +61,6 @@ THREE.SSAOShader = {
 		"#define DL 2.399963229728653",  // PI * ( 3.0 - sqrt( 5.0 ) )
 		"#define EULER 2.718281828459045",
 
-		// helpers
-
-		"float width = size.x;",   // texture width
-		"float height = size.y;",  // texture height
-
-		"float cameraFarPlusNear = cameraFar + cameraNear;",
-		"float cameraFarMinusNear = cameraFar - cameraNear;",
-		"float cameraCoef = 2.0 * cameraNear;",
-
 		// user variables
 
 		"const int samples = 8;",     // ao sample count
@@ -107,8 +98,8 @@ THREE.SSAOShader = {
 
 			"} else {",
 
-				"float ff = fract( 1.0 - coord.s * ( width / 2.0 ) );",
-				"float gg = fract( coord.t * ( height / 2.0 ) );",
+				"float ff = fract( 1.0 - coord.s * ( size.x / 2.0 ) );",
+				"float gg = fract( coord.t * ( size.y / 2.0 ) );",
 
 				"noise = vec2( 0.25, 0.75 ) * vec2( ff ) + vec2( 0.75, 0.25 ) * gg;",
 
@@ -120,6 +111,10 @@ THREE.SSAOShader = {
 
 		"float readDepth( const in vec2 coord ) {",
 
+			"float cameraFarPlusNear = cameraFar + cameraNear;",
+			"float cameraFarMinusNear = cameraFar - cameraNear;",
+			"float cameraCoef = 2.0 * cameraNear;",
+
 			// "return ( 2.0 * cameraNear ) / ( cameraFar + cameraNear - unpackDepth( texture2D( tDepth, coord ) ) * ( cameraFar - cameraNear ) );",
 			"return cameraCoef / ( cameraFarPlusNear - unpackDepth( texture2D( tDepth, coord ) ) * cameraFarMinusNear );",
 
@@ -183,8 +178,8 @@ THREE.SSAOShader = {
 
 			"float tt = clamp( depth, aoClamp, 1.0 );",
 
-			"float w = ( 1.0 / width )  / tt + ( noise.x * ( 1.0 - noise.x ) );",
-			"float h = ( 1.0 / height ) / tt + ( noise.y * ( 1.0 - noise.y ) );",
+			"float w = ( 1.0 / size.x )  / tt + ( noise.x * ( 1.0 - noise.x ) );",
+			"float h = ( 1.0 / size.y ) / tt + ( noise.y * ( 1.0 - noise.y ) );",
 
 			"float ao = 0.0;",