Browse Source

Merge branch 'dev' of https://github.com/mrdoob/three.js into dev

Mr.doob 10 years ago
parent
commit
8a52e630d9

+ 2 - 2
examples/js/ShaderDeferred.js

@@ -241,7 +241,7 @@ THREE.ShaderDeferred = {
 
 
 					"} else {",
 					"} else {",
 
 
-						"outgoingLight = mix( outgoingLight.xyz, diffuseColor.xyz * cubeColor.xyz, specularStrength * reflectivity );",
+						"outgoingLight = mix( outgoingLight, diffuseColor.xyz * cubeColor.xyz, specularStrength * reflectivity );",
 
 
 					"}",
 					"}",
 
 
@@ -270,7 +270,7 @@ THREE.ShaderDeferred = {
 
 
 				// diffuse color
 				// diffuse color
 
 
-				"gl_FragColor.x = vec3_to_float( compressionScale * outgoingLight.xyz );",
+				"gl_FragColor.x = vec3_to_float( compressionScale * outgoingLight );",
 
 
 				// specular color
 				// specular color
 
 

+ 2 - 2
examples/js/shaders/NormalDisplacementShader.js

@@ -387,7 +387,7 @@ THREE.NormalDisplacementShader = {
 
 
 		"	#ifdef METAL",
 		"	#ifdef METAL",
 
 
-		"		outgoingLight += diffuseColor.xyz * ( totalDiffuseLight + ambientLightColor * diffuse + totalSpecularLight );",
+		"		outgoingLight += diffuseColor.xyz * ( totalDiffuseLight + ambientLightColor + totalSpecularLight );",
 
 
 		"	#else",
 		"	#else",
 
 
@@ -417,7 +417,7 @@ THREE.NormalDisplacementShader = {
 
 
 		"		#endif",
 		"		#endif",
 
 
-		"		outgoingLight = mix( outgoingLight.xyz, cubeColor.xyz, specularTex.r * reflectivity );",
+		"		outgoingLight = mix( outgoingLight, cubeColor.xyz, specularTex.r * reflectivity );",
 
 
 		"	}",
 		"	}",
 
 

+ 0 - 3
src/renderers/shaders/ShaderChunk/lights_lambert_pars_vertex.glsl

@@ -1,6 +1,3 @@
-uniform vec3 diffuse;
-uniform vec3 emissive;
-
 uniform vec3 ambientLightColor;
 uniform vec3 ambientLightColor;
 
 
 #if MAX_DIR_LIGHTS > 0
 #if MAX_DIR_LIGHTS > 0

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

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

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

@@ -234,7 +234,7 @@ vec3 totalSpecularLight = vec3( 0.0 );
 
 
 #ifdef METAL
 #ifdef METAL
 
 
-	outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + ambientLightColor * diffuse ) * specular + totalSpecularLight + emissive;
+	outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + ambientLightColor ) * specular + totalSpecularLight + emissive;
 
 
 #else
 #else
 
 

+ 7 - 4
src/renderers/shaders/ShaderLib.js

@@ -171,8 +171,11 @@ THREE.ShaderLib = {
 
 
 		fragmentShader: [
 		fragmentShader: [
 
 
+			"uniform vec3 diffuse;",
 			"uniform float opacity;",
 			"uniform float opacity;",
 
 
+			"uniform vec3 emissive;",
+
 			"varying vec3 vLightFront;",
 			"varying vec3 vLightFront;",
 
 
 			"#ifdef DOUBLE_SIDED",
 			"#ifdef DOUBLE_SIDED",
@@ -195,7 +198,7 @@ THREE.ShaderLib = {
 			"void main() {",
 			"void main() {",
 
 
 			"	vec3 outgoingLight = vec3( 0.0 );",	// outgoing light does not have an alpha, the surface does
 			"	vec3 outgoingLight = vec3( 0.0 );",	// outgoing light does not have an alpha, the surface does
-			"	vec4 diffuseColor = vec4( 1.0, 1.0, 1.0, opacity );",
+			"	vec4 diffuseColor = vec4( diffuse, opacity );",
 
 
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
 				THREE.ShaderChunk[ "logdepthbuf_fragment" ],
 				THREE.ShaderChunk[ "map_fragment" ],
 				THREE.ShaderChunk[ "map_fragment" ],
@@ -210,13 +213,13 @@ THREE.ShaderLib = {
 					//"gl_FragColor.xyz *= isFront * vLightFront + ( 1.0 - isFront ) * vLightBack;",
 					//"gl_FragColor.xyz *= isFront * vLightFront + ( 1.0 - isFront ) * vLightBack;",
 
 
 			"		if ( gl_FrontFacing )",
 			"		if ( gl_FrontFacing )",
-			"			outgoingLight += diffuseColor.rgb * vLightFront;",
+			"			outgoingLight += diffuseColor.rgb * vLightFront + emissive;",
 			"		else",
 			"		else",
-			"			outgoingLight += diffuseColor.rgb * vLightBack;",
+			"			outgoingLight += diffuseColor.rgb * vLightBack + emissive;",
 
 
 			"	#else",
 			"	#else",
 
 
-			"		outgoingLight += diffuseColor.rgb * vLightFront;",
+			"		outgoingLight += diffuseColor.rgb * vLightFront + emissive;",
 
 
 			"	#endif",
 			"	#endif",