summaryrefslogtreecommitdiff
path: root/src/renderergl2/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderergl2/glsl')
-rw-r--r--src/renderergl2/glsl/lightall_fp.glsl13
-rw-r--r--src/renderergl2/glsl/lightall_vp.glsl31
2 files changed, 29 insertions, 15 deletions
diff --git a/src/renderergl2/glsl/lightall_fp.glsl b/src/renderergl2/glsl/lightall_fp.glsl
index f223bb0c..53fd1b43 100644
--- a/src/renderergl2/glsl/lightall_fp.glsl
+++ b/src/renderergl2/glsl/lightall_fp.glsl
@@ -24,6 +24,10 @@ uniform sampler2D u_ShadowMap;
uniform samplerCube u_CubeMap;
#endif
+#if defined(USE_NORMALMAP) || defined(USE_DELUXEMAP) || defined(USE_SPECULARMAP) || defined(USE_CUBEMAP)
+uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube
+#endif
+
#if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
uniform vec3 u_DirectedLight;
uniform vec3 u_AmbientLight;
@@ -52,7 +56,7 @@ varying vec4 var_Bitangent;
varying vec3 var_LightColor;
#endif
-#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
varying vec4 var_LightDir;
#endif
@@ -304,6 +308,7 @@ void main()
#if defined(USE_TANGENT_SPACE_LIGHT)
L = L * tangentToWorld;
#endif
+ L = L * u_EnableTextures.y + var_LightDir.xyz;
#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
L = var_LightDir.xyz;
#endif
@@ -352,6 +357,7 @@ void main()
#else
N.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - vec2(1.0);
#endif
+ N.xy *= u_EnableTextures.x;
N.z = sqrt(1.0 - clamp(dot(N.xy, N.xy), 0.0, 1.0));
#if !defined(USE_TANGENT_SPACE_LIGHT)
N = normalize(tangentToWorld * N);
@@ -412,6 +418,7 @@ void main()
#if defined(USE_SPECULARMAP)
vec4 specular = texture2D(u_SpecularMap, texCoords);
+ specular = mix(vec4(1.0), specular, u_EnableTextures.z);
#if defined(USE_GAMMA2_TEXTURES)
specular.rgb *= specular.rgb;
#endif
@@ -470,7 +477,7 @@ void main()
R = tangentToWorld * R;
#endif
- vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb;
+ vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w;
#if defined(USE_LIGHTMAP)
cubeLightColor *= lightSample.rgb;
@@ -480,7 +487,7 @@ void main()
cubeLightColor *= lightColor * NL + ambientColor;
#endif
- //gl_FragColor.rgb += diffuse.rgb * textureCubeLod(u_CubeMap, N, 7.0).rgb;
+ //gl_FragColor.rgb += diffuse.rgb * textureCubeLod(u_CubeMap, N, 7.0).rgb * u_EnableTextures.w;
gl_FragColor.rgb += cubeLightColor * reflectance;
#endif
diff --git a/src/renderergl2/glsl/lightall_vp.glsl b/src/renderergl2/glsl/lightall_vp.glsl
index ce83d10a..284b3973 100644
--- a/src/renderergl2/glsl/lightall_vp.glsl
+++ b/src/renderergl2/glsl/lightall_vp.glsl
@@ -20,15 +20,19 @@ attribute vec3 attr_Bitangent2;
attribute vec3 attr_LightDirection;
#endif
-#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
+#if defined(USE_DELUXEMAP)
+uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube
+#endif
+
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
uniform vec3 u_ViewOrigin;
-uniform vec3 u_LocalViewOrigin;
#endif
#if defined(USE_TCGEN)
uniform int u_TCGen0;
uniform vec3 u_TCGen0Vector0;
uniform vec3 u_TCGen0Vector1;
+uniform vec3 u_LocalViewOrigin;
#endif
#if defined(USE_TCMOD)
@@ -51,8 +55,8 @@ uniform float u_VertexLerp;
#if defined(USE_LIGHT_VECTOR)
uniform vec4 u_LightOrigin;
uniform float u_LightRadius;
-uniform vec3 u_DirectedLight;
#if defined(USE_FAST_LIGHT)
+uniform vec3 u_DirectedLight;
uniform vec3 u_AmbientLight;
#endif
#endif
@@ -66,7 +70,7 @@ varying vec4 var_TexCoords;
varying vec4 var_Color;
-#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
varying vec4 var_Normal;
varying vec4 var_Tangent;
varying vec4 var_Bitangent;
@@ -76,7 +80,7 @@ varying vec4 var_Bitangent;
varying vec3 var_LightColor;
#endif
-#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
varying vec4 var_LightDir;
#endif
@@ -150,7 +154,7 @@ float CalcLightAttenuation(vec3 dir, float sqrRadius)
void main()
{
#if defined(USE_VERTEX_ANIMATION)
- vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);
+ vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);
vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));
vec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp));
vec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp));
@@ -184,7 +188,7 @@ void main()
#if defined(USE_LIGHT_VECTOR)
vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w);
-#elif defined(USE_LIGHT) && !defined(USE_DELUXEMAP)
+#elif defined(USE_LIGHT)
vec3 L = attr_LightDirection;
#if defined(USE_MODELMATRIX)
L = (u_ModelMatrix * vec4(L, 0.0)).xyz;
@@ -213,15 +217,18 @@ void main()
var_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius;
#endif
-#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
#if defined(USE_LIGHT_VECTOR)
var_LightDir = vec4(L, u_LightRadius * u_LightRadius);
#else
var_LightDir = vec4(L, 0.0);
#endif
+ #if defined(USE_DELUXEMAP)
+ var_LightDir *= 1.0 - u_EnableTextures.y;
+ #endif
#endif
-#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
vec3 viewDir = u_ViewOrigin - position;
#endif
@@ -232,16 +239,16 @@ void main()
var_PrimaryLightDir.xyz = var_PrimaryLightDir.xyz * tangentToWorld;
#endif
- #if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)
+ #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
var_LightDir.xyz = var_LightDir.xyz * tangentToWorld;
#endif
- #if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)
+ #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
viewDir = viewDir * tangentToWorld;
#endif
#endif
-#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)
+#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
// store view direction in tangent space to save on varyings
var_Normal = vec4(normal, viewDir.x);
var_Tangent = vec4(tangent, viewDir.y);