提交 fd500a63 编写于 作者: B Ben Houston

ensure that lightMap is modulated by surface color and then added to resulting fragColor.

上级 209c8e1c
#ifdef USE_LIGHTMAP
gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
#if defined( PHONG )
gl_FragColor += diffuseColor * texture2D( lightMap, vUv2 );
#else
gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );
#endif
#endif
\ No newline at end of file
......@@ -33,7 +33,7 @@ vec3 viewPosition = normalize( vViewPosition );
lVector = normalize( lVector );
// diffuse
// diffuse
float dotProduct = dot( normal, lVector );
......@@ -50,7 +50,7 @@ vec3 viewPosition = normalize( vViewPosition );
#endif
pointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;
pointDiffuse += pointLightColor[ i ] * pointDiffuseWeight * lDistance;
// specular
......@@ -89,7 +89,7 @@ vec3 viewPosition = normalize( vViewPosition );
spotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );
// diffuse
// diffuse
float dotProduct = dot( normal, lVector );
......@@ -106,9 +106,9 @@ vec3 viewPosition = normalize( vViewPosition );
#endif
spotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;
spotDiffuse += spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;
// specular
// specular
vec3 spotHalfVector = normalize( lVector + viewPosition );
float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );
......@@ -135,7 +135,7 @@ vec3 viewPosition = normalize( vViewPosition );
vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );
vec3 dirVector = normalize( lDirection.xyz );
// diffuse
// diffuse
float dotProduct = dot( normal, dirVector );
......@@ -152,7 +152,7 @@ vec3 viewPosition = normalize( vViewPosition );
#endif
dirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;
dirDiffuse += directionalLightColor[ i ] * dirDiffuseWeight;
// specular
......@@ -208,7 +208,7 @@ vec3 viewPosition = normalize( vViewPosition );
vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );
hemiDiffuse += diffuse * hemiColor;
hemiDiffuse += hemiColor;
// specular (sky light)
......@@ -269,10 +269,10 @@ vec3 totalSpecular = vec3( 0.0 );
#ifdef METAL
gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );
gl_FragColor.xyz = diffuseColor * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );
#else
gl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;
gl_FragColor.xyz = diffuseColor * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;
#endif
\ No newline at end of file
......@@ -9,5 +9,11 @@
#endif
gl_FragColor = gl_FragColor * texelColor;
#if defined( PHONG )
diffuseColor *= texelColor.xyz;
#endif
#endif
\ No newline at end of file
......@@ -186,7 +186,7 @@ THREE.ShaderLib = {
"void main() {",
" gl_FragColor = vec4( vec3( 1.0 ), opacity );",
THREE.ShaderChunk[ "logdepthbuf_fragment" ],
THREE.ShaderChunk[ "map_fragment" ],
THREE.ShaderChunk[ "alphamap_fragment" ],
......@@ -319,6 +319,7 @@ THREE.ShaderLib = {
"void main() {",
" gl_FragColor = vec4( vec3( 1.0 ), opacity );",
" vec3 diffuseColor = diffuse;",
THREE.ShaderChunk[ "logdepthbuf_fragment" ],
THREE.ShaderChunk[ "map_fragment" ],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册