|
|
|
@ -42,6 +42,13 @@ uniform sampler2D specularMap;
|
|
|
|
|
varying vec2 specularMapUV;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if @bumpMap
|
|
|
|
|
uniform sampler2D bumpMap;
|
|
|
|
|
varying vec2 bumpMapUV;
|
|
|
|
|
uniform vec2 envMapLumaBias;
|
|
|
|
|
uniform mat2 bumpMapMatrix;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
varying float depth;
|
|
|
|
|
|
|
|
|
|
#define PER_PIXEL_LIGHTING (@normalMap || @forcePPL)
|
|
|
|
@ -132,20 +139,24 @@ void main()
|
|
|
|
|
gl_FragData[0].xyz += texture2D(emissiveMap, emissiveMapUV).xyz;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if @envMap
|
|
|
|
|
vec2 texCoordGen = envMapUV;
|
|
|
|
|
float envLuma = 1.0;
|
|
|
|
|
|
|
|
|
|
#if @normalMap
|
|
|
|
|
// if using normal map + env map, take advantage of per-pixel normals for texCoordGen
|
|
|
|
|
vec3 viewVec = normalize(passViewPos.xyz);
|
|
|
|
|
vec3 r = reflect( viewVec, viewNormal );
|
|
|
|
|
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
|
|
|
|
|
vec2 texCoordGen = vec2(r.x/m + 0.5, r.y/m + 0.5);
|
|
|
|
|
gl_FragData[0].xyz += texture2D(envMap, texCoordGen).xyz * envMapColor.xyz;
|
|
|
|
|
#else
|
|
|
|
|
gl_FragData[0].xyz += texture2D(envMap, envMapUV).xyz * envMapColor.xyz;
|
|
|
|
|
texCoordGen = vec2(r.x/m + 0.5, r.y/m + 0.5);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if @bumpMap
|
|
|
|
|
vec4 bumpTex = texture2D(bumpMap, bumpMapUV);
|
|
|
|
|
texCoordGen += bumpTex.rg * bumpMapMatrix;
|
|
|
|
|
envLuma = clamp(bumpTex.b * envMapLumaBias.x + envMapLumaBias.y, 0.0, 1.0);
|
|
|
|
|
#endif
|
|
|
|
|
gl_FragData[0].xyz += texture2D(envMap, texCoordGen).xyz * envMapColor.xyz * envLuma;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if @specularMap
|
|
|
|
|