Browse Source

Fixed specular light vs black texture bug in Phong shader.

alteredq 14 năm trước cách đây
mục cha
commit
fd0fb85c8e

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
build/Three.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
build/custom/ThreeWebGL.js


+ 1 - 1
examples/webgl_materials.html

@@ -77,7 +77,7 @@
 				//materials.push( new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ) );
 				//materials.push( new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ) );
 
 
 				materials.push( new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.SmoothShading } ) );
 				materials.push( new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.SmoothShading } ) );
-				materials.push( new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.SmoothShading } ) );
+				materials.push( new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.SmoothShading, map: THREE.ImageUtils.loadTexture( "textures/planets/earth_specular_2048.jpg" ) } ) );
 				materials.push( new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ) );
 				materials.push( new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ) );
 				materials.push( new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ) );
 				materials.push( new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ) );
 
 

+ 7 - 4
src/renderers/WebGLShaders.js

@@ -391,21 +391,24 @@ THREE.ShaderChunk = {
 
 
 	"#endif",
 	"#endif",
 
 
-	"vec4 totalLight = vec4( ambient, opacity );",
+	"vec4 totalDiffuse = vec4( vec3( 0.0 ), opacity );",
+	"vec4 totalSpecular = vec4( ambient, opacity );",
 
 
 	"#if MAX_DIR_LIGHTS > 0",
 	"#if MAX_DIR_LIGHTS > 0",
 
 
-		"totalLight += dirDiffuse + dirSpecular;",
+		"totalDiffuse += dirDiffuse;",
+		"totalSpecular += dirSpecular;",
 
 
 	"#endif",
 	"#endif",
 
 
 	"#if MAX_POINT_LIGHTS > 0",
 	"#if MAX_POINT_LIGHTS > 0",
 
 
-		"totalLight += pointDiffuse + pointSpecular;",
+		"totalDiffuse += pointDiffuse;",
+		"totalSpecular += pointSpecular;",
 
 
 	"#endif",
 	"#endif",
 
 
-	"gl_FragColor = gl_FragColor * totalLight;"
+	"gl_FragColor = gl_FragColor * totalDiffuse + totalSpecular;"
 
 
 	].join("\n"),
 	].join("\n"),
 
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác