Browse Source

SSAOShader: Fixed uninitialised float. Should fix #3425.

Mr.doob 11 years ago
parent
commit
57175b7658
1 changed files with 3 additions and 6 deletions
  1. 3 6
      examples/js/shaders/SSAOShader.js

+ 3 - 6
examples/js/shaders/SSAOShader.js

@@ -206,10 +206,7 @@ THREE.SSAOShader = {
 			"float w = ( 1.0 / width )  / tt + ( noise.x * ( 1.0 - noise.x ) );",
 			"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 h = ( 1.0 / height ) / tt + ( noise.y * ( 1.0 - noise.y ) );",
 
 
-			"float pw;",
-			"float ph;",
-
-			"float ao;",
+			"float ao = 0.0;",
 
 
 			"float dz = 1.0 / float( samples );",
 			"float dz = 1.0 / float( samples );",
 			"float z = 1.0 - dz / 2.0;",
 			"float z = 1.0 - dz / 2.0;",
@@ -219,8 +216,8 @@ THREE.SSAOShader = {
 
 
 				"float r = sqrt( 1.0 - z );",
 				"float r = sqrt( 1.0 - z );",
 
 
-				"pw = cos( l ) * r;",
-				"ph = sin( l ) * r;",
+				"float pw = cos( l ) * r;",
+				"float ph = sin( l ) * r;",
 				"ao += calcAO( depth, pw * w, ph * h );",
 				"ao += calcAO( depth, pw * w, ph * h );",
 				"z = z - dz;",
 				"z = z - dz;",
 				"l = l + DL;",
 				"l = l + DL;",