|
@@ -74,29 +74,43 @@ THREE.ShaderDeferred = {
|
|
|
|
|
|
"const float compressionScale = 0.999;",
|
|
"const float compressionScale = 0.999;",
|
|
|
|
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ "vec3 diffuseMapColor;",
|
|
|
|
+
|
|
|
|
+ "#ifdef USE_MAP",
|
|
|
|
+
|
|
|
|
+ "diffuseMapColor = texelColor.xyz;",
|
|
|
|
+
|
|
|
|
+ "#else",
|
|
|
|
+
|
|
|
|
+ "diffuseMapColor = vec3( 1.0 );",
|
|
|
|
+
|
|
|
|
+ "#endif",
|
|
|
|
+
|
|
// diffuse color
|
|
// diffuse color
|
|
|
|
|
|
"gl_FragColor.x = vec3_to_float( compressionScale * gl_FragColor.xyz );",
|
|
"gl_FragColor.x = vec3_to_float( compressionScale * gl_FragColor.xyz );",
|
|
|
|
|
|
// specular color
|
|
// specular color
|
|
|
|
|
|
- "gl_FragColor.y = additiveSpecular * vec3_to_float( compressionScale * specular );",
|
|
|
|
|
|
+ "if ( additiveSpecular < 0.0 ) {",
|
|
|
|
|
|
- // shininess
|
|
|
|
|
|
+ "gl_FragColor.y = vec3_to_float( compressionScale * specular );",
|
|
|
|
|
|
- "gl_FragColor.z = wrapAround * shininess;",
|
|
|
|
|
|
+ "} else {",
|
|
|
|
|
|
- // emissive color
|
|
|
|
|
|
+ "gl_FragColor.y = vec3_to_float( compressionScale * specular * diffuseMapColor );",
|
|
|
|
|
|
- "#ifdef USE_MAP",
|
|
|
|
|
|
+ "}",
|
|
|
|
|
|
- "gl_FragColor.w = vec3_to_float( compressionScale * emissive * texelColor.xyz );",
|
|
|
|
|
|
+ // shininess
|
|
|
|
|
|
- "#else",
|
|
|
|
|
|
+ "gl_FragColor.z = wrapAround * shininess;",
|
|
|
|
|
|
- "gl_FragColor.w = vec3_to_float( compressionScale * emissive );",
|
|
|
|
|
|
+ // emissive color
|
|
|
|
|
|
- "#endif",
|
|
|
|
|
|
+ "gl_FragColor.w = vec3_to_float( compressionScale * emissive * diffuseMapColor );",
|
|
|
|
|
|
"}"
|
|
"}"
|
|
|
|
|
|
@@ -396,18 +410,7 @@ THREE.ShaderDeferred = {
|
|
// combine
|
|
// combine
|
|
|
|
|
|
"vec3 light = lightIntensity * lightColor;",
|
|
"vec3 light = lightIntensity * lightColor;",
|
|
-
|
|
|
|
- "float additiveSpecular = sign( colorMap.y );",
|
|
|
|
-
|
|
|
|
- "if ( additiveSpecular < 0.0 ) {",
|
|
|
|
-
|
|
|
|
- "gl_FragColor = vec4( albedo * light * diffuse, attenuation ) + vec4( light * specular, attenuation );",
|
|
|
|
-
|
|
|
|
- "} else {",
|
|
|
|
-
|
|
|
|
- "gl_FragColor = vec4( albedo * light * ( diffuse + specular ), attenuation );",
|
|
|
|
-
|
|
|
|
- "}",
|
|
|
|
|
|
+ "gl_FragColor = vec4( albedo * light * diffuse, attenuation ) + vec4( light * specular, attenuation );",
|
|
|
|
|
|
"}"
|
|
"}"
|
|
|
|
|