diff options
author | Brad Kittenbrink <brad@lindenlab.com> | 2008-02-27 18:58:14 +0000 |
---|---|---|
committer | Brad Kittenbrink <brad@lindenlab.com> | 2008-02-27 18:58:14 +0000 |
commit | 6d52efe452aa8469e0343da1c7d108f3f52ab651 (patch) | |
tree | a87be48e9840d7fc1f7ee514d7c7f994e71fdb3c /indra/newview/app_settings/shaders/class1/lighting | |
parent | 6027ad2630b8650cabcf00628ee9b0d25bedd67f (diff) |
Merge of windlight into release (QAR-286). This includes all changes in
windlight14 which have passed QA (up through r79932).
svn merge -r 80831:80833 svn+ssh://svn.lindenlab.com/svn/linden/branches/merge_windlight14_r80620
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/lighting')
13 files changed, 278 insertions, 105 deletions
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl index c169fceb88..9ab986be6d 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl @@ -1,31 +1,15 @@ -void applyScatter(inout vec3 color); +/** + * @file lightF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ uniform sampler2D diffuseMap; void default_lighting() { - vec4 color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); - //applyScatter(color.rgb); + color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); gl_FragColor = color; } -void alpha_lighting() -{ - default_lighting(); -} - -void water_lighting(inout vec3 diff) -{ - applyScatter(diff); -} - -void terrain_lighting(inout vec3 color) -{ - color.rgb *= gl_Color.rgb; - applyScatter(color); -} - -vec4 getLightColor() -{ - return gl_Color; -}
\ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl new file mode 100644 index 0000000000..b12cca9126 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl @@ -0,0 +1,15 @@ +/** + * @file lightFullbrightF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +uniform sampler2D diffuseMap; + +void fullbright_lighting() +{ + gl_FragColor = texture2D(diffuseMap, gl_TexCoord[0].xy); +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl new file mode 100644 index 0000000000..bc795a7513 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl @@ -0,0 +1,15 @@ +/** + * @file lightFullbrightShinyF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +uniform sampler2D diffuseMap; +uniform samplerCube environmentMap; + +void fullbright_shiny_lighting() +{ + gl_FragColor = texture2D(diffuseMap, gl_TexCoord[0].xy); +} diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl new file mode 100644 index 0000000000..b13088fb19 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl @@ -0,0 +1,15 @@ +/** + * @file lightFullbrightWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +uniform sampler2D diffuseMap; + +void fullbright_lighting_water() +{ + gl_FragColor = texture2D(diffuseMap, gl_TexCoord[0].xy); +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl new file mode 100644 index 0000000000..bbbd9f3dfe --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl @@ -0,0 +1,46 @@ +/** + * @file lightFuncSpecularV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +float calcDirectionalLight(vec3 n, vec3 l) +{ + float a = max(dot(n,l),0.0); + return a; +} + +float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l) +{ + return pow(max(dot(reflect(view, n),l), 0.0),8.0); +} + +float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da) +{ + + specular.rgb += calcDirectionalSpecular(view,n,l)*lightCol*da; + return max(dot(n,l),0.0); +} + +vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol) +{ + //get light vector + vec3 lv = l-v; + + //get distance + float d = length(lv); + + //normalize light vector + lv *= 1.0/d; + + //distance attenuation + float da = clamp(1.0/(r * d), 0.0, 1.0); + + //angular attenuation + + da *= calcDirectionalLightSpecular(specular, view, n, lv, lightCol, da); + + return da*lightCol; +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl new file mode 100644 index 0000000000..3e8fdfb3e4 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl @@ -0,0 +1,34 @@ +/** + * @file lightFuncV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +float calcDirectionalLight(vec3 n, vec3 l) +{ + float a = max(dot(n,l),0.0); + return a; +} + +float calcPointLight(vec3 v, vec3 n, vec4 lp, float la) +{ + //get light vector + vec3 lv = lp.xyz-v; + + //get distance + float d = length(lv); + + //normalize light vector + lv *= 1.0/d; + + //distance attenuation + float da = clamp(1.0/(la * d), 0.0, 1.0); + + //angular attenuation + da *= calcDirectionalLight(n, lv); + + return da; +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl new file mode 100644 index 0000000000..c6f7f8b81b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl @@ -0,0 +1,17 @@ +/** + * @file lightShinyF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +uniform sampler2D diffuseMap; +uniform samplerCube environmentMap; + +void shiny_lighting() +{ + color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); + 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 new file mode 100644 index 0000000000..75f61ccdf1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl @@ -0,0 +1,17 @@ +/** + * @file lightShinyWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +uniform sampler2D diffuseMap; +uniform samplerCube environmentMap; + +void shiny_lighting_water() +{ + color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl new file mode 100644 index 0000000000..853212923c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl @@ -0,0 +1,26 @@ +/** + * @file lightV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +float calcDirectionalLight(vec3 n, vec3 l); + +// 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 = gl_LightModel.ambient.rgb + baseCol.rgb; + + col.rgb += gl_LightSource[0].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[0].position.xyz); + col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); + + col.rgb = min(col.rgb*color.rgb, 1.0); + + return col; +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl index e3816318a1..8c2813a859 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl @@ -1,66 +1,11 @@ +/** + * @file lightV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -float calcDirectionalLight(vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return a; -} - -float calcPointLight(vec3 v, vec3 n, vec3 l, float r, float pw) -{ - //get light vector - vec3 lv = l-v; - - //get distance - float d = length(lv); - - //normalize light vector - lv *= 1.0/d; - - //distance attenuation - float da = max((r-d)/r, 0.0); - - //da = pow(da, pw); - - //angular attenuation - da *= calcDirectionalLight(n, lv); - - return da; -} - -float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l) -{ - float a = max(dot(n,l),0.0); - return a; -} - -float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da) -{ - - specular.rgb += calcDirectionalSpecular(view,n,l)*lightCol*da; - return calcDirectionalLight(n,l); -} - -vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol) -{ - //get light vector - vec3 lv = l-v; - - //get distance - float d = length(lv); - - //normalize light vector - lv *= 1.0/d; - - //distance attenuation - float da = clamp((r-d)/r, 0.0, 1.0); - - //da = pow(da, pw); - - //angular attenuation - da *= calcDirectionalLightSpecular(specular, view, n, lv, lightCol, da); - - return da*lightCol; -} +float calcDirectionalLight(vec3 n, vec3 l); vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) { @@ -77,23 +22,3 @@ vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) return col; } -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseLight) -{ - return calcLighting(pos, norm, color, vec4(baseLight, 1.0)); -} - -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color) -{ - return calcLighting(pos, norm, color, vec3(0.0,0.0,0.0)); -} - -vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol) -{ - specularColor.rgb = vec3(0.0, 0.0, 0.0); - return calcLighting(pos, norm, color, baseCol); -} - -vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol) -{ - return calcLightingSpecular(pos, norm, color, specularColor, vec4(baseCol, 1.0)); -} diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl new file mode 100644 index 0000000000..81dff1ef39 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl @@ -0,0 +1,15 @@ +/** + * @file lightWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; + +void default_lighting_water() +{ + vec4 color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class1/lighting/sumLightsSpecularV.glsl b/indra/newview/app_settings/shaders/class1/lighting/sumLightsSpecularV.glsl new file mode 100644 index 0000000000..218585fb86 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/sumLightsSpecularV.glsl @@ -0,0 +1,35 @@ +/** + * @file sumLightsSpecularV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ +float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da); +vec3 atmosAmbient(vec3 light); +vec3 atmosAffectDirectionalLight(float lightIntensity); +vec3 atmosGetDiffuseSunlightColor(); +vec3 scaleDownLight(vec3 light); + +vec4 sumLightsSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol) +{ + vec4 col; + col.a = color.a; + + + vec3 view = normalize(pos); + + /// collect all the specular values from each calcXXXLightSpecular() function + vec4 specularSum = vec4(0.0); + + col.rgb = gl_LightSource[1].diffuse.rgb * calcDirectionalLightSpecular(specularColor, view, norm, gl_LightSource[1].position.xyz, gl_LightSource[1].diffuse.rgb, 1.0); + col.rgb = scaleDownLight(col.rgb); + col.rgb += atmosAmbient(baseCol.rgb); + col.rgb += atmosAffectDirectionalLight(calcDirectionalLightSpecular(specularSum, view, norm, gl_LightSource[0].position.xyz,atmosGetDiffuseSunlightColor() * baseCol.a, 1.0)); + + col.rgb = min(col.rgb * color.rgb, 1.0); + specularColor.rgb = min(specularColor.rgb * specularSum.rgb, 1.0); + + col.rgb += specularColor.rgb; + + return col; +} diff --git a/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl new file mode 100644 index 0000000000..e5361033ef --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl @@ -0,0 +1,29 @@ +/** + * @file sumLightsV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +float calcDirectionalLight(vec3 n, vec3 l); + +vec3 atmosAmbient(vec3 light); +vec3 atmosAffectDirectionalLight(float lightIntensity); +vec3 scaleDownLight(vec3 light); + +vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) +{ + vec4 col; + col.a = color.a; + + col.rgb = gl_LightSource[1].diffuse.rgb * calcDirectionalLight(norm, gl_LightSource[1].position.xyz); + col.rgb = scaleDownLight(col.rgb); + col.rgb += atmosAmbient(baseLight.rgb); + col.rgb += atmosAffectDirectionalLight(calcDirectionalLight(norm, gl_LightSource[0].position.xyz)); + + col.rgb = min(col.rgb*color.rgb, 1.0); + + return col; +} + + |