Browse Source

WebGLRenderer: Fixed MeshPhongMaterial+FlatShaded+Flip/DoubleSide. See #6117.

Mr.doob 10 years ago
parent
commit
1b0ac10c96
1 changed files with 6 additions and 6 deletions
  1. 6 6
      src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl

+ 6 - 6
src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl

@@ -2,6 +2,12 @@
 
 
 	vec3 normal = normalize( vNormal );
 	vec3 normal = normalize( vNormal );
 
 
+	#ifdef DOUBLE_SIDED
+
+		normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );
+
+	#endif
+
 #else
 #else
 
 
 	vec3 fdx = dFdx( vViewPosition );
 	vec3 fdx = dFdx( vViewPosition );
@@ -12,12 +18,6 @@
 
 
 vec3 viewPosition = normalize( vViewPosition );
 vec3 viewPosition = normalize( vViewPosition );
 
 
-#ifdef DOUBLE_SIDED
-
-	normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );
-
-#endif
-
 #ifdef USE_NORMALMAP
 #ifdef USE_NORMALMAP
 
 
 	normal = perturbNormal2Arb( -vViewPosition, normal );
 	normal = perturbNormal2Arb( -vViewPosition, normal );