Browse Source

cleaner use of diffuse.

Ben Houston 9 years ago
parent
commit
d74476069f
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl

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

@@ -2,9 +2,11 @@ vec3 viewDir = normalize( vViewPosition );
 
 vec3 totalReflectedLight = vec3( 0.0 );
 
+var diffuse = diffuseColor.rgb;
+
 #ifdef METAL
 
-	diffuseColor.rgb = diffuseColor.rgb * specular;
+	diffuse *= specular;
 
 #endif
 
@@ -23,7 +25,7 @@ vec3 totalReflectedLight = vec3( 0.0 );
 			float dotLH = saturate( dot( lightDir, halfDir ) );
 
 			totalReflectedLight += (
-				BRDF_Lambert( diffuseColor.rgb, dotNL ) +
+				BRDF_Lambert( diffuse, dotNL ) +
 				BRDF_BlinnPhong( specular, shininess, dotNH, dotLH )
 				) * lightIntensity;
 
@@ -48,7 +50,7 @@ vec3 totalReflectedLight = vec3( 0.0 );
 			float dotLH = saturate( dot( lightDir, halfDir ) );
 
 			totalReflectedLight += (
-				BRDF_Lambert( diffuseColor.rgb, dotNL ) +
+				BRDF_Lambert( diffuse, dotNL ) +
 				BRDF_BlinnPhong( specular, shininess, dotNH, dotLH )
 				) * lightIntensity;
 
@@ -73,7 +75,7 @@ vec3 totalReflectedLight = vec3( 0.0 );
 			float dotLH = saturate( dot( lightDir, halfDir ) );
 
 			totalReflectedLight += (
-				BRDF_Lambert( diffuseColor.rgb, dotNL ) +
+				BRDF_Lambert( diffuse, dotNL ) +
 				BRDF_BlinnPhong( specular, shininess, dotNH, dotLH )
 				) * lightIntensity;