From 7238714634e72dacc4b09c1c4ee98b16fb0c91fe Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 29 Sep 2011 19:32:56 -0500 Subject: SH-2507 Potential fix for basic shaders causing objects to disappear with some drivers (prune shader tree of unused shaders while we're at it) --- .../shaders/class1/lighting/lightF.glsl | 12 +++++++--- .../shaders/class1/lighting/lightFullbrightF.glsl | 17 ++++++++++---- .../class1/lighting/lightFullbrightShinyF.glsl | 26 +++++++++++++++++---- .../lighting/lightFullbrightShinyWaterF.glsl | 27 +++++++++++++++++----- .../class1/lighting/lightFullbrightWaterF.glsl | 14 ++++++++--- .../shaders/class1/lighting/lightShinyF.glsl | 19 ++++++++++++--- .../shaders/class1/lighting/lightShinyWaterF.glsl | 18 +++++++++++---- .../shaders/class1/lighting/lightSpecularV.glsl | 23 ++++-------------- .../shaders/class1/lighting/lightV.glsl | 19 ++++----------- .../shaders/class1/lighting/lightWaterF.glsl | 16 ++++++++----- 10 files changed, 123 insertions(+), 68 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/lighting') diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl index 8274a655db..735f5b3813 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl @@ -22,7 +22,7 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + #ifdef DEFINE_GL_FRAGCOLOR out vec4 gl_FragColor; #endif @@ -30,11 +30,17 @@ out vec4 gl_FragColor; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -uniform sampler2D diffuseMap; +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); void default_lighting() { - vec4 color = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy); + vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + gl_FragColor = color; } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl index ec7ec9ae7d..c3edc0bd70 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl @@ -22,18 +22,25 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + #ifdef DEFINE_GL_FRAGCOLOR out vec4 gl_FragColor; #endif - -uniform sampler2D diffuseMap; - +VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + void fullbright_lighting() { - gl_FragColor = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; + + color.rgb = fullbrightAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + gl_FragColor = color; } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl index d47d1724a7..c981e9eba2 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl @@ -22,18 +22,34 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + #ifdef DEFINE_GL_FRAGCOLOR out vec4 gl_FragColor; #endif +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; +VARYING vec3 vary_texcoord1; -uniform sampler2D diffuseMap; uniform samplerCube environmentMap; -VARYING vec2 vary_texcoord0; +vec3 fullbrightShinyAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); -void fullbright_shiny_lighting() +void fullbright_shiny_lighting() { - gl_FragColor = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 color = diffuseLookup(vary_texcoord0.xy); + color.rgb *= vertex_color.rgb; + + vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); + + color.rgb = fullbrightShinyAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + color.a = max(color.a, vertex_color.a); + + gl_FragColor = color; } + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl index bd67e2659e..c10cde98e0 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyWaterF.glsl @@ -21,18 +21,33 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - + #ifdef DEFINE_GL_FRAGCOLOR out vec4 gl_FragColor; -#endif +#endif +VARYING vec4 vertex_color; +VARYING vec2 vary_texcoord0; +VARYING vec3 vary_texcoord1; -uniform sampler2D diffuseMap; uniform samplerCube environmentMap; -VARYING vec2 vary_texcoord0; +vec3 fullbrightShinyAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); +vec4 applyWaterFog(vec4 color); -void fullbright_shiny_lighting_water() +void fullbright_shiny_lighting_water() { - gl_FragColor = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 color = diffuseLookup(vary_texcoord0.xy); + color.rgb *= vertex_color.rgb; + + vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); + + color.rgb = fullbrightShinyAtmosTransport(color.rgb); + color.rgb = fullbrightScaleSoftClip(color.rgb); + color.a = max(color.a, vertex_color.a); + + gl_FragColor = applyWaterFog(color); } + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl index 0cf5152661..2547f9e750 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl @@ -27,12 +27,20 @@ out vec4 gl_FragColor; #endif -uniform sampler2D diffuseMap; - +VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +vec4 diffuseLookup(vec2 texcoord); + +vec3 fullbrightAtmosTransport(vec3 light); +vec4 applyWaterFog(vec4 color); + void fullbright_lighting_water() { - gl_FragColor = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; + + color.rgb = fullbrightAtmosTransport(color.rgb); + + gl_FragColor = applyWaterFog(color); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl index 761bda487d..e9c27dbefd 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl @@ -29,13 +29,26 @@ out vec4 gl_FragColor; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +VARYING vec3 vary_texcoord1; -uniform sampler2D diffuseMap; uniform samplerCube environmentMap; -void shiny_lighting() +vec3 scaleSoftClip(vec3 light); +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void shiny_lighting() { - vec4 color = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy); + vec4 color = diffuseLookup(vary_texcoord0.xy); + color.rgb *= vertex_color.rgb; + + vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + color.a = max(color.a, vertex_color.a); gl_FragColor = color; } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl index 6761d35316..68c727d62c 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl @@ -29,13 +29,23 @@ out vec4 gl_FragColor; VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; +VARYING vec3 vary_texcoord1; -uniform sampler2D diffuseMap; uniform samplerCube environmentMap; -void shiny_lighting_water() +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void shiny_lighting_water() { - vec4 color = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy); - gl_FragColor = color; + vec4 color = diffuseLookup(vary_texcoord0.xy); + color.rgb *= vertex_color.rgb; + + vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a); + + color.rgb = atmosLighting(color.rgb); + color.a = max(color.a, vertex_color.a); + gl_FragColor = applyWaterFog(color); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl index 265d548ce9..24bf9b3cee 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl @@ -1,5 +1,5 @@ /** - * @file lightV.glsl + * @file lightSpecularV.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code @@ -24,26 +24,13 @@ */ -uniform vec4 light_position[8]; -uniform vec3 light_diffuse[8]; -uniform vec4 light_ambient; -float calcDirectionalLight(vec3 n, vec3 l); +// All lights, no specular highlights + +vec4 sumLightsSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol); -// Same as non-specular lighting in lightV.glsl vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol) { - specularColor.rgb = vec3(0.0, 0.0, 0.0); - vec4 col; - col.a = color.a; - - col.rgb = baseCol.rgb + light_ambient.rgb; - - col.rgb += light_diffuse[0].rgb*calcDirectionalLight(norm, light_position[0].xyz); - col.rgb += light_diffuse[1].rgb*calcDirectionalLight(norm, light_position[1].xyz); - - col.rgb = min(col.rgb*color.rgb, 1.0); - - return col; + return sumLightsSpecular(pos, norm, color, specularColor, baseCol); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl index b886f97743..8045809b82 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl @@ -24,24 +24,13 @@ */ -uniform vec4 light_position[8]; -uniform vec3 light_diffuse[8]; -uniform vec4 light_ambient; -float calcDirectionalLight(vec3 n, vec3 l); +// All lights, no specular highlights + +vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight); vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) { - vec4 col; - col.a = color.a; - - col.rgb = baseLight.rgb+light_ambient.rgb; - - col.rgb += light_diffuse[0].rgb*calcDirectionalLight(norm, light_position[0].xyz); - col.rgb += light_diffuse[1].rgb*calcDirectionalLight(norm, light_position[1].xyz); - - col.rgb = min(col.rgb*color.rgb, 1.0); - - return col; + return sumLights(pos, norm, color, baseLight); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl index 2908d77443..e9537d1e9d 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl @@ -25,16 +25,20 @@ #ifdef DEFINE_GL_FRAGCOLOR out vec4 gl_FragColor; -#endif - +#endif + VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; -uniform sampler2D diffuseMap; +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); -void default_lighting_water() +void default_lighting_water() { - vec4 color = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy); - gl_FragColor = color; + vec4 color = diffuseLookup(vary_texcoord0.xy) * vertex_color; + + color.rgb = atmosLighting(color.rgb); + + gl_FragColor = applyWaterFog(color); } -- cgit v1.2.3