Browse Source

WebGLDeferredRenderer: a bit better emissive color.

Taking into account also original material texture (if it exists).
alteredq 12 years ago
parent
commit
aff0f9d204

+ 4 - 7
build/three.js

@@ -14625,19 +14625,16 @@ THREE.ShaderChunk = {
 
 		"#ifdef USE_MAP",
 
+			"vec4 texelColor = texture2D( map, vUv );",
+
 			"#ifdef GAMMA_INPUT",
 
-				"vec4 texelColor = texture2D( map, vUv );",
 				"texelColor.xyz *= texelColor.xyz;",
 
-				"gl_FragColor = gl_FragColor * texelColor;",
-
-			"#else",
-
-				"gl_FragColor = gl_FragColor * texture2D( map, vUv );",
-
 			"#endif",
 
+			"gl_FragColor = gl_FragColor * texelColor;",
+
 		"#endif"
 
 	].join("\n"),

File diff suppressed because it is too large
+ 2 - 2
build/three.min.js


+ 15 - 3
examples/js/ShaderDeferred.js

@@ -68,13 +68,17 @@ THREE.ShaderDeferred = {
 
 				THREE.ShaderChunk[ "fog_fragment" ],
 
+				//
+
+				"const float compressionScale = 0.999;",
+
 				// diffuse color
 
-				"gl_FragColor.x = vec3_to_float( 0.999 * gl_FragColor.xyz );",
+				"gl_FragColor.x = vec3_to_float( compressionScale * gl_FragColor.xyz );",
 
 				// specular color
 
-				"gl_FragColor.y = vec3_to_float( 0.999 * specular );",
+				"gl_FragColor.y = vec3_to_float( compressionScale * specular );",
 
 				// shininess
 
@@ -82,7 +86,15 @@ THREE.ShaderDeferred = {
 
 				// emissive color
 
-				"gl_FragColor.w = vec3_to_float( 0.999 * emissive );",
+				"#ifdef USE_MAP",
+
+					"gl_FragColor.w = vec3_to_float( compressionScale * emissive * texelColor.xyz );",
+
+				"#else",
+
+					"gl_FragColor.w = vec3_to_float( compressionScale * emissive );",
+
+				"#endif",
 
 			"}"
 

+ 2 - 2
examples/webgl_lights_deferred_pointlights.html

@@ -254,7 +254,7 @@
 				var loader = new THREE.BinaryLoader();
 				loader.load( "obj/female02/Female02_bin.js", function( geometry, materials ) {
 
-					var material = new THREE.MeshPhongMaterial( { shininess: 175, specular: 0x999999, wrapAround: true } );
+					for ( var i = 0; i < materials.length; i ++ ) materials[ i ].wrapAround = true;
 
 					var object = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
 					object.position.x = -50;
@@ -266,7 +266,7 @@
 
 				loader.load( "obj/male02/Male02_bin.js", function( geometry, materials ) {
 
-					var material = new THREE.MeshPhongMaterial( { shininess: 175, specular: 0x999999, wrapAround: true } );
+					for ( var i = 0; i < materials.length; i ++ ) materials[ i ].wrapAround = true;
 
 					var object = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ) );
 					object.position.x = 50;

+ 4 - 7
src/renderers/WebGLShaders.js

@@ -268,19 +268,16 @@ THREE.ShaderChunk = {
 
 		"#ifdef USE_MAP",
 
+			"vec4 texelColor = texture2D( map, vUv );",
+
 			"#ifdef GAMMA_INPUT",
 
-				"vec4 texelColor = texture2D( map, vUv );",
 				"texelColor.xyz *= texelColor.xyz;",
 
-				"gl_FragColor = gl_FragColor * texelColor;",
-
-			"#else",
-
-				"gl_FragColor = gl_FragColor * texture2D( map, vUv );",
-
 			"#endif",
 
+			"gl_FragColor = gl_FragColor * texelColor;",
+
 		"#endif"
 
 	].join("\n"),

Some files were not shown because too many files changed in this diff