Browse Source

Calculate envmap reflection vector for the phong material per fragment

resolves #5058
Jan Wrobel 11 years ago
parent
commit
d1b37e0c35

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

@@ -2,7 +2,7 @@
 
 	vec3 reflectVec;
 
-	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
+	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
 
 		vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
 

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

@@ -5,7 +5,7 @@
 	uniform float flipEnvMap;
 	uniform int combine;
 
-	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )
+	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
 
 		uniform bool useRefract;
 		uniform float refractionRatio;

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

@@ -1,4 +1,4 @@
-#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )
+#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )
 
 	varying vec3 vReflect;
 

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

@@ -1,4 +1,4 @@
-#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )
+#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )
 
 	vec3 worldNormal = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;
 	worldNormal = normalize( worldNormal );

+ 2 - 0
src/renderers/shaders/ShaderLib.js

@@ -293,6 +293,8 @@ THREE.ShaderLib = {
 
 		fragmentShader: [
 
+			"#define PHONG",
+
 			"uniform vec3 diffuse;",
 			"uniform float opacity;",