Sfoglia il codice sorgente

minimize algorithm changes based on @WestLangley feedback here: https://github.com/mrdoob/three.js/pull/5809#issuecomment-68023021

Ben Houston 10 anni fa
parent
commit
263109a251

+ 3 - 3
src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl

@@ -193,10 +193,10 @@ for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
 
 #endif
 
-vLightFront = ( vLightFront + ambientLightColor ) * diffuse + emissive;
+vLightFront = vLightFront * diffuse + diffuse * ambientLightColor + emissive;
 
 #ifdef DOUBLE_SIDED
 
-	vLightBack = ( ambientLightColor + vLightBack ) * diffuse + emissive;
-
+	vLightBack = vLightBack * diffuse + diffuse * ambientLightColor + emissive;
+	
 #endif

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

@@ -269,10 +269,10 @@ vec3 totalSpecular = vec3( 0.0 );
 
 #ifdef METAL
 
-	gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor + totalSpecular );
+	gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * diffuse + totalSpecular );
 
 #else
 
-	gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor ) + totalSpecular;
+	gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * diffuse ) + totalSpecular;
 
 #endif