From 6d52efe452aa8469e0343da1c7d108f3f52ab651 Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Wed, 27 Feb 2008 18:58:14 +0000 Subject: 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 --- .../shaders/class1/avatar/avatarF.glsl | 7 + .../shaders/class1/avatar/avatarSkinV.glsl | 7 +- .../shaders/class1/avatar/avatarV.glsl | 22 +- .../shaders/class1/avatar/eyeballF.glsl | 7 + .../shaders/class1/avatar/eyeballV.glsl | 19 +- .../shaders/class1/avatar/pickAvatarF.glsl | 7 + .../shaders/class1/avatar/pickAvatarV.glsl | 10 +- .../shaders/class1/effects/glowExtractF.glsl | 28 +++ .../shaders/class1/effects/glowExtractV.glsl | 14 ++ .../app_settings/shaders/class1/effects/glowF.glsl | 31 +++ .../app_settings/shaders/class1/effects/glowV.glsl | 22 ++ .../shaders/class1/environment/terrainF.glsl | 16 +- .../shaders/class1/environment/terrainV.glsl | 13 +- .../shaders/class1/environment/terrainWaterF.glsl | 23 +++ .../shaders/class1/environment/underWaterF.glsl | 45 +++++ .../shaders/class1/environment/waterF.glsl | 96 +++++++-- .../shaders/class1/environment/waterFogF.glsl | 20 ++ .../shaders/class1/environment/waterV.glsl | 90 ++++++--- .../shaders/class1/interface/highlightF.glsl | 7 + .../shaders/class1/interface/highlightV.glsl | 15 +- .../shaders/class1/lighting/lightF.glsl | 30 +-- .../shaders/class1/lighting/lightFullbrightF.glsl | 15 ++ .../class1/lighting/lightFullbrightShinyF.glsl | 15 ++ .../class1/lighting/lightFullbrightWaterF.glsl | 15 ++ .../class1/lighting/lightFuncSpecularV.glsl | 46 +++++ .../shaders/class1/lighting/lightFuncV.glsl | 34 ++++ .../shaders/class1/lighting/lightShinyF.glsl | 17 ++ .../shaders/class1/lighting/lightShinyWaterF.glsl | 17 ++ .../shaders/class1/lighting/lightSpecularV.glsl | 26 +++ .../shaders/class1/lighting/lightV.glsl | 89 +------- .../shaders/class1/lighting/lightWaterF.glsl | 15 ++ .../class1/lighting/sumLightsSpecularV.glsl | 35 ++++ .../shaders/class1/lighting/sumLightsV.glsl | 29 +++ .../shaders/class1/objects/fullbrightF.glsl | 13 ++ .../shaders/class1/objects/fullbrightShinyF.glsl | 13 ++ .../shaders/class1/objects/fullbrightShinyV.glsl | 29 +++ .../shaders/class1/objects/fullbrightV.glsl | 23 +++ .../shaders/class1/objects/fullbrightWaterF.glsl | 13 ++ .../shaders/class1/objects/shinyF.glsl | 16 +- .../shaders/class1/objects/shinyV.glsl | 25 ++- .../shaders/class1/objects/shinyWaterF.glsl | 13 ++ .../shaders/class1/objects/simpleF.glsl | 7 + .../shaders/class1/objects/simpleV.glsl | 22 +- .../shaders/class1/objects/simpleWaterF.glsl | 13 ++ .../shaders/class1/windlight/atmosphericsF.glsl | 13 ++ .../class1/windlight/atmosphericsHelpersV.glsl | 34 ++++ .../shaders/class1/windlight/atmosphericsV.glsl | 15 ++ .../class1/windlight/atmosphericsVarsF.glsl | 13 ++ .../class1/windlight/atmosphericsVarsV.glsl | 19 ++ .../shaders/class1/windlight/gammaF.glsl | 19 ++ .../shaders/class1/windlight/transportF.glsl | 26 +++ .../shaders/class2/avatar/eyeballV.glsl | 21 +- .../app_settings/shaders/class2/effects/blurF.glsl | 31 +++ .../app_settings/shaders/class2/effects/blurV.glsl | 35 ++++ .../shaders/class2/effects/colorFilterF.glsl | 31 +++ .../shaders/class2/effects/drawQuadV.glsl | 14 ++ .../shaders/class2/effects/extractF.glsl | 22 ++ .../shaders/class2/effects/nightVisionF.glsl | 42 ++++ .../shaders/class2/effects/simpleF.glsl | 14 ++ .../shaders/class2/environment/terrainF.glsl | 38 ++++ .../shaders/class2/environment/terrainV.glsl | 52 +++++ .../shaders/class2/environment/terrainWaterF.glsl | 39 ++++ .../shaders/class2/environment/underWaterF.glsl | 88 ++++++++ .../shaders/class2/environment/waterF.glsl | 223 ++++++++++----------- .../shaders/class2/environment/waterFogF.glsl | 54 +++++ .../shaders/class2/lighting/lightF.glsl | 41 ++-- .../shaders/class2/lighting/lightFullbrightF.glsl | 23 +++ .../class2/lighting/lightFullbrightShinyF.glsl | 30 +++ .../class2/lighting/lightFullbrightWaterF.glsl | 21 ++ .../shaders/class2/lighting/lightShinyF.glsl | 29 +++ .../shaders/class2/lighting/lightShinyWaterF.glsl | 27 +++ .../shaders/class2/lighting/lightSpecularV.glsl | 16 ++ .../shaders/class2/lighting/lightV.glsl | 128 +----------- .../shaders/class2/lighting/lightWaterF.glsl | 21 ++ .../class2/lighting/sumLightsSpecularV.glsl | 41 ++++ .../shaders/class2/lighting/sumLightsV.glsl | 34 ++++ .../shaders/class2/objects/shinyV.glsl | 31 +++ .../shaders/class2/windlight/atmosphericsF.glsl | 24 +++ .../class2/windlight/atmosphericsHelpersV.glsl | 41 ++++ .../shaders/class2/windlight/atmosphericsV.glsl | 137 +++++++++++++ .../class2/windlight/atmosphericsVarsF.glsl | 34 ++++ .../class2/windlight/atmosphericsVarsV.glsl | 60 ++++++ .../shaders/class2/windlight/cloudsF.glsl | 76 +++++++ .../shaders/class2/windlight/cloudsV.glsl | 163 +++++++++++++++ .../shaders/class2/windlight/gammaF.glsl | 24 +++ .../shaders/class2/windlight/skyF.glsl | 41 ++++ .../shaders/class2/windlight/skyV.glsl | 138 +++++++++++++ .../shaders/class2/windlight/transportF.glsl | 35 ++++ .../shaders/class3/avatar/avatarV.glsl | 112 +++++------ .../class3/lighting/sumLightsSpecularV.glsl | 44 ++++ .../shaders/class3/lighting/sumLightsV.glsl | 41 ++++ .../app_settings/shaders/shader_heirarchy.txt | 176 ++++++++++++++++ 92 files changed, 2954 insertions(+), 546 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/effects/glowF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/effects/glowV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightShinyF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFuncSpecularV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightShinyF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightShinyWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightSpecularV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/sumLightsSpecularV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl create mode 100755 indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/objects/fullbrightShinyF.glsl create mode 100755 indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl create mode 100755 indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl create mode 100755 indra/newview/app_settings/shaders/class1/objects/fullbrightWaterF.glsl create mode 100755 indra/newview/app_settings/shaders/class1/objects/shinyWaterF.glsl create mode 100755 indra/newview/app_settings/shaders/class1/objects/simpleWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl create mode 100644 indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl create mode 100644 indra/newview/app_settings/shaders/class1/windlight/transportF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/effects/blurF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/effects/blurV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/effects/extractF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/effects/simpleF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/environment/terrainF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/environment/terrainV.glsl create mode 100755 indra/newview/app_settings/shaders/class2/environment/terrainWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/environment/underWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/environment/waterFogF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/lightFullbrightF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/lightShinyF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/lightSpecularV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/lightWaterF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl create mode 100755 indra/newview/app_settings/shaders/class2/objects/shinyV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/skyF.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/skyV.glsl create mode 100644 indra/newview/app_settings/shaders/class2/windlight/transportF.glsl create mode 100644 indra/newview/app_settings/shaders/class3/lighting/sumLightsSpecularV.glsl create mode 100644 indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl create mode 100644 indra/newview/app_settings/shaders/shader_heirarchy.txt (limited to 'indra/newview/app_settings/shaders') diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl index 5731add4d5..b6cc7f7712 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl @@ -1,3 +1,10 @@ +/** + * @file avatarF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + void default_lighting(); void main() diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl index 1fcc001911..292dbfdab4 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl @@ -1,4 +1,9 @@ -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color); +/** + * @file avatarSkinV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ attribute vec4 weight; //1 diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl index 50f9b0192e..ee3410d732 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl @@ -1,9 +1,13 @@ -void default_scatter(vec3 viewVec, vec3 lightDir); +/** + * @file avatarV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); mat4 getSkinnedTransform(); -vec2 getScatterCoord(vec3 viewVec, vec3 lightDir); - -attribute vec4 materialColor; +void calcAtmospherics(vec3 inPositionEye); void main() { @@ -24,12 +28,16 @@ void main() norm = normalize(norm); gl_Position = gl_ProjectionMatrix * pos; - + //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - default_scatter(pos.xyz, gl_LightSource[0].position.xyz); + gl_FogFragCoord = length(pos.xyz); - vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color); + calcAtmospherics(pos.xyz); + + vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0,0,0,0)); gl_FrontColor = color; } + + diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl index 5731add4d5..4d93c19441 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl @@ -1,3 +1,10 @@ +/** + * @file eyeballF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + void default_lighting(); void main() diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl index d436b4e00a..b3c988a924 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl @@ -1,7 +1,12 @@ -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseCol); -void default_scatter(vec3 viewVec, vec3 lightDir); +/** + * @file eyeballV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -attribute vec4 materialColor; +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol); +void calcAtmospherics(vec3 inPositionEye); void main() { @@ -12,9 +17,11 @@ void main() vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; vec3 norm = normalize(gl_NormalMatrix * gl_Normal); - vec4 color = calcLighting(pos, norm, materialColor, gl_Color.rgb); - default_scatter(pos, gl_LightSource[0].position.xyz); - + calcAtmospherics(pos.xyz); + + vec4 specular = vec4(1.0); + vec4 color = calcLightingSpecular(pos, norm, gl_Color, specular, vec4(0.0)); gl_FrontColor = color; + } diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl index b311afb59c..2019300418 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl @@ -1,3 +1,10 @@ +/** + * @file pickAvatarF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + uniform sampler2D diffuseMap; void main() diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl index b6dcbe1693..12d8f9d2f9 100644 --- a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl +++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl @@ -1,4 +1,10 @@ -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color); +/** + * @file pickAvatarV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + mat4 getSkinnedTransform(); void main() @@ -14,4 +20,4 @@ void main() gl_FrontColor = gl_Color; gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = gl_ProjectionMatrix * pos; -} \ No newline at end of file +} diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl new file mode 100644 index 0000000000..dbdfe1174c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl @@ -0,0 +1,28 @@ +/** + * @file glowExtractF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +#extension GL_ARB_texture_rectangle : enable + +uniform sampler2DRect diffuseMap; +uniform float minLuminance; +uniform float maxExtractAlpha; +uniform vec3 lumWeights; +uniform vec3 warmthWeights; +uniform float warmthAmount; + +void main() +{ + vec4 col = texture2DRect(diffuseMap, gl_TexCoord[0].xy); + + /// CALCULATING LUMINANCE (Using NTSC lum weights) + /// http://en.wikipedia.org/wiki/Luma_%28video%29 + float lum = smoothstep(minLuminance, 1.0, dot(col.rgb, lumWeights ) ); + float warmth = smoothstep(minLuminance, 1.0, max(col.r * warmthWeights.r, max(col.g * warmthWeights.g, col.b * warmthWeights.b)) ); + + gl_FragColor.rgb = col.rgb; + gl_FragColor.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha); +} diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl new file mode 100644 index 0000000000..61dfd2f126 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl @@ -0,0 +1,14 @@ +/** + * @file glowExtractV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + gl_TexCoord[0].xy = gl_MultiTexCoord0.xy; +} diff --git a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl new file mode 100644 index 0000000000..21c7ad765f --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl @@ -0,0 +1,31 @@ +/** + * @file glowF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; +uniform float glowStrength; + +void main() +{ + + vec4 col = vec4(0.0, 0.0, 0.0, 0.0); + + // ATI compiler falls down on array initialization. + float kern[8]; + kern[0] = 0.25; kern[1] = 0.5; kern[2] = 0.8; kern[3] = 1.0; + kern[4] = 1.0; kern[5] = 0.8; kern[6] = 0.5; kern[7] = 0.25; + + col += kern[0] * texture2D(diffuseMap, gl_TexCoord[0].xy); + col += kern[1] * texture2D(diffuseMap, gl_TexCoord[1].xy); + col += kern[2] * texture2D(diffuseMap, gl_TexCoord[2].xy); + col += kern[3] * texture2D(diffuseMap, gl_TexCoord[3].xy); + col += kern[4] * texture2D(diffuseMap, gl_TexCoord[0].zw); + col += kern[5] * texture2D(diffuseMap, gl_TexCoord[1].zw); + col += kern[6] * texture2D(diffuseMap, gl_TexCoord[2].zw); + col += kern[7] * texture2D(diffuseMap, gl_TexCoord[3].zw); + + gl_FragColor = vec4(col.rgb * glowStrength, col.a); +} diff --git a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl new file mode 100644 index 0000000000..13ce7c7854 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl @@ -0,0 +1,22 @@ +/** + * @file glowV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform vec2 glowDelta; + +void main() +{ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + gl_TexCoord[0].xy = gl_MultiTexCoord0.xy + glowDelta*(-3.5); + gl_TexCoord[1].xy = gl_MultiTexCoord0.xy + glowDelta*(-2.5); + gl_TexCoord[2].xy = gl_MultiTexCoord0.xy + glowDelta*(-1.5); + gl_TexCoord[3].xy = gl_MultiTexCoord0.xy + glowDelta*(-0.5); + gl_TexCoord[0].zw = gl_MultiTexCoord0.xy + glowDelta*(0.5); + gl_TexCoord[1].zw = gl_MultiTexCoord0.xy + glowDelta*(1.5); + gl_TexCoord[2].zw = gl_MultiTexCoord0.xy + glowDelta*(2.5); + gl_TexCoord[3].zw = gl_MultiTexCoord0.xy + glowDelta*(3.5); +} diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl index fde370155d..2278c6916d 100644 --- a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl @@ -1,9 +1,13 @@ -void terrain_lighting(inout vec3 color); - -uniform sampler2D detail0; //0 -uniform sampler2D detail1; //2 -uniform sampler2D alphaRamp; //1 +/** + * @file terrainF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ +uniform sampler2D detail0; +uniform sampler2D detail1; +uniform sampler2D alphaRamp; void main() { @@ -12,8 +16,6 @@ void main() texture2D(detail0, gl_TexCoord[0].xy).rgb, a); - terrain_lighting(color); - gl_FragColor.rgb = color; gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a; } diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl index 3153a80e93..112d669819 100644 --- a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl @@ -1,7 +1,11 @@ -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); -void default_scatter(vec3 viewVec, vec3 lightDir); +/** + * @file terrainV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -attribute vec4 materialColor; +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) { @@ -25,7 +29,7 @@ void main() vec4 pos = gl_ModelViewMatrix * gl_Vertex; vec3 norm = normalize(gl_NormalMatrix * gl_Normal); - vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color); + vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), gl_Color); gl_FrontColor = color; @@ -33,5 +37,4 @@ void main() gl_TexCoord[1] = gl_TextureMatrix[1]*gl_MultiTexCoord1; gl_TexCoord[2] = texgen_object(gl_Vertex,gl_MultiTexCoord2,gl_TextureMatrix[2],gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]); gl_TexCoord[3] = gl_TextureMatrix[3]*gl_MultiTexCoord3; - default_scatter(pos.xyz, gl_LightSource[0].position.xyz); } diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl new file mode 100644 index 0000000000..e2f68e8826 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl @@ -0,0 +1,23 @@ +/** + * @file terrainWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +// this class1 shader is just a copy of terrainF + +uniform sampler2D detail0; +uniform sampler2D detail1; +uniform sampler2D alphaRamp; + +void main() +{ + float a = texture2D(alphaRamp, gl_TexCoord[1].xy).a; + vec3 color = mix(texture2D(detail1, gl_TexCoord[2].xy).rgb, + texture2D(detail0, gl_TexCoord[0].xy).rgb, + a); + + gl_FragColor.rgb = color; + gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a; +} diff --git a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl new file mode 100644 index 0000000000..f1740a4dcd --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl @@ -0,0 +1,45 @@ +/** + * @file underWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; +uniform sampler2D bumpMap; +uniform sampler2D screenTex; + +uniform float refScale; +uniform vec4 waterFogColor; + +//bigWave is (refCoord.w, view.w); +varying vec4 refCoord; +varying vec4 littleWave; +varying vec4 view; + +void main() +{ + vec4 color; + + //get bigwave normal + vec3 wavef = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0; + + //get detail normals + vec3 dcol = texture2D(bumpMap, littleWave.xy).rgb*0.75; + dcol += texture2D(bumpMap, littleWave.zw).rgb*1.25; + + //interpolate between big waves and little waves (big waves in deep water) + wavef = (wavef+dcol)*0.5; + + //crunch normal to range [-1,1] + wavef -= vec3(1,1,1); + + //figure out distortion vector (ripply) + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + distort = distort+wavef.xy*refScale; + + vec4 fb = texture2D(screenTex, distort); + + gl_FragColor.rgb = mix(waterFogColor.rgb, fb.rgb, waterFogColor.a * 0.001 + 0.999); + gl_FragColor.a = fb.a; +} diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index f8b8031ce6..1c14381df9 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -1,22 +1,94 @@ -void water_lighting(inout vec3 diff); +/** + * @file waterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +vec3 scaleSoftClip(vec3 inColor); +vec3 atmosTransport(vec3 inColor); -uniform samplerCube environmentMap; uniform sampler2D diffuseMap; -uniform sampler2D bumpMap; +uniform sampler2D bumpMap; +uniform sampler2D screenTex; +uniform sampler2D refTex; + +uniform float sunAngle; +uniform float sunAngle2; +uniform float scaledAngle; +uniform vec3 lightDir; +uniform vec3 specular; +uniform float lightExp; +uniform float refScale; +uniform float kd; +uniform vec2 screenRes; +uniform vec3 normScale; +uniform float fresnelScale; +uniform float fresnelOffset; +uniform float blurMultiplier; +uniform vec4 fogCol; -varying vec4 specular; +//bigWave is (refCoord.w, view.w); +varying vec4 refCoord; +varying vec4 littleWave; +varying vec4 view; void main() { - vec4 depth = texture2D(diffuseMap, gl_TexCoord[0].xy); - vec4 diff = texture2D(bumpMap, gl_TexCoord[1].xy); - vec3 ref = textureCube(environmentMap, gl_TexCoord[2].xyz).rgb; + vec3 viewVec = view.xyz; + vec4 color; + + float dist = length(viewVec.xy); + + //normalize view vector + viewVec = normalize(viewVec); + + //get wave normals + vec3 wavef = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0; + + //get detail normals + vec3 dcol = texture2D(bumpMap, littleWave.xy).rgb*0.75; + dcol += texture2D(bumpMap, littleWave.zw).rgb*1.25; + + //interpolate between big waves and little waves (big waves in deep water) + wavef = (wavef + dcol) * 0.5; + + //crunch normal to range [-1,1] + wavef -= vec3(1,1,1); + wavef = normalize(wavef); + + //get base fresnel components - diff.rgb *= depth.rgb; + float df = dot(viewVec,wavef) * fresnelScale + fresnelOffset; + + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + + float dist2 = dist; + dist = max(dist, 5.0); + + //get reflected color + vec2 refdistort = wavef.xy*dot(normScale, vec3(0.333)); + vec2 refvec = distort+refdistort/dist; + vec4 refcol = texture2D(refTex, refvec); + + //get specular component + float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); + + //harden specular + spec = pow(spec, lightExp); + + //figure out distortion vector (ripply) + vec2 distort2 = distort+wavef.xy*refScale/max(dist*df, 1.0); - vec3 col = mix(diff.rgb, ref, specular.a)+specular.rgb*diff.rgb; + vec4 fb = texture2D(screenTex, distort2); + + //mix with reflection + color.rgb = mix(mix(fogCol.rgb, fb.rgb, fogCol.a), refcol.rgb, df); + color.rgb += spec * specular; - water_lighting(col.rgb); - gl_FragColor.rgb = col.rgb; - gl_FragColor.a = (gl_Color.a+depth.a)*0.5; + color.rgb = atmosTransport(color.rgb); + color.rgb = scaleSoftClip(color.rgb); + color.a = spec * sunAngle2; + + gl_FragColor = color; } diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl new file mode 100644 index 0000000000..59e44fa871 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl @@ -0,0 +1,20 @@ +/** + * @file waterFogF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +vec4 applyWaterFog(vec4 color) +{ + // GL_EXP2 Fog + float fog = exp(-gl_Fog.density * gl_Fog.density * gl_FogFragCoord * gl_FogFragCoord); + // GL_EXP Fog + // float fog = exp(-gl_Fog.density * gl_FogFragCoord); + // GL_LINEAR Fog + // float fog = (gl_Fog.end - gl_FogFragCoord) * gl_Fog.scale; + fog = clamp(fog, 0.0, 1.0); + color.rgb = mix(gl_Fog.color.rgb, color.rgb, fog); + return color; +} + diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl index 873a6fcb34..d332798103 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl @@ -1,41 +1,73 @@ -void default_scatter(vec3 viewVec, vec3 lightDir); -vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol); -vec2 getScatterCoord(vec3 viewVec, vec3 lightDir); +/** + * @file waterV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -varying vec4 specular; +void calcAtmospherics(vec3 inPositionEye); -vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) +uniform vec2 d1; +uniform vec2 d2; +uniform float time; +uniform vec3 eyeVec; +uniform float waterHeight; + +varying vec4 refCoord; +varying vec4 littleWave; +varying vec4 view; + +float wave(vec2 v, float t, float f, vec2 d, float s) { - vec4 tcoord; - - tcoord.x = dot(vpos, tp0); - tcoord.y = dot(vpos, tp1); - tcoord.z = tc.z; - tcoord.w = tc.w; - - tcoord = mat * tcoord; - - return tcoord; + return (dot(d, v)*f + t*s)*f; } void main() { //transform vertex - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_TexCoord[1] = texgen_object(gl_Vertex, gl_MultiTexCoord1, gl_TextureMatrix[1], gl_ObjectPlaneS[1],gl_ObjectPlaneT[1]); + vec4 position = gl_Vertex; + mat4 modelViewProj = gl_ModelViewProjectionMatrix; - vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; - vec3 norm = normalize(gl_NormalMatrix * gl_Normal); - vec4 spec = gl_Color; - gl_FrontColor.rgb = calcLightingSpecular(pos, norm, gl_Color, spec, vec3(0.0, 0.0, 0.0)).rgb; - gl_FrontColor.a = gl_Color.a; - specular = spec; - specular.a = gl_Color.a*0.5; - vec3 ref = reflect(pos,norm); + vec4 oPosition; + + //get view vector + vec3 oEyeVec; + oEyeVec.xyz = position.xyz-eyeVec; + + float d = length(oEyeVec.xy); + float ld = min(d, 2560.0); - gl_TexCoord[2] = gl_TextureMatrix[2]*vec4(ref,1); + position.xy = eyeVec.xy + oEyeVec.xy/d*ld; + view.xyz = oEyeVec; + + d = clamp(ld/1536.0-0.5, 0.0, 1.0); + d *= d; - default_scatter(pos.xyz, gl_LightSource[0].position.xyz); + oPosition = position; + oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); + oPosition = modelViewProj * oPosition; + refCoord.xyz = oPosition.xyz + vec3(0,0,0.2); + + //get wave position parameter (create sweeping horizontal waves) + vec3 v = position.xyz; + v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0; + + //push position for further horizon effect. + position.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z); + position.w = 1.0; + position = position*gl_ModelViewMatrix; + + calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz); + + + //pass wave parameters to pixel shader + vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055; + //get two normal map (detail map) texture coordinates + littleWave.xy = (v.xy) * vec2(0.6, 1.2) + d2 * time * 0.05; + // littleWave.zw = (v.xy) * vec2(0.07, 0.15) - d1 * time * 0.043; + littleWave.zw = (v.xy) * vec2(0.3, 0.6) + d1 * time * 0.1; + view.w = bigWave.y; + refCoord.w = bigWave.x; + + gl_Position = oPosition; } - diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl index 1e342fb51b..328c41652d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl @@ -1,3 +1,10 @@ +/** + * @file highlightF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + uniform sampler2D diffuseMap; void main() diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl index bb6707b2a9..a9ea6e856a 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl @@ -1,9 +1,14 @@ -attribute vec4 materialColor; +/** + * @file highlightV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ void main() { //transform vertex - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_Position = ftransform(); vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; pos = normalize(pos); float d = dot(pos, normalize(gl_NormalMatrix * gl_Normal)); @@ -11,10 +16,10 @@ void main() d = 1.0 - d; d *= d; - d = min(d, materialColor.a*2.0); + d = min(d, gl_Color.a*2.0); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - gl_FrontColor.rgb = materialColor.rgb; - gl_FrontColor.a = max(d, materialColor.a); + gl_FrontColor.rgb = gl_Color.rgb; + gl_FrontColor.a = max(d, gl_Color.a); } 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; +} + + diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl new file mode 100755 index 0000000000..1b0ffb911a --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightF.glsl @@ -0,0 +1,13 @@ +/** + * @file fullbrightF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void fullbright_lighting(); + +void main() +{ + fullbright_lighting(); +} diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyF.glsl new file mode 100644 index 0000000000..936c228b4e --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyF.glsl @@ -0,0 +1,13 @@ +/** + * @file fullbrightShinyF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void fullbright_shiny_lighting(); + +void main() +{ + fullbright_shiny_lighting(); +} diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl new file mode 100755 index 0000000000..ba2aa024dc --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl @@ -0,0 +1,29 @@ +/** + * @file fullbrightShinyV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void calcAtmospherics(vec3 inPositionEye); + +uniform vec4 origin; + +void main() +{ + //transform vertex + gl_Position = ftransform(); + + vec4 pos = (gl_ModelViewMatrix * gl_Vertex); + vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + vec3 ref = reflect(pos.xyz, -norm); + + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0); + + calcAtmospherics(pos.xyz); + + gl_FrontColor = gl_Color; + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl new file mode 100755 index 0000000000..e64ccb844d --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl @@ -0,0 +1,23 @@ +/** + * @file fullbrightV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void calcAtmospherics(vec3 inPositionEye); + +void main() +{ + //transform vertex + gl_Position = ftransform(); + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + + vec4 pos = (gl_ModelViewMatrix * gl_Vertex); + + calcAtmospherics(pos.xyz); + + gl_FrontColor = gl_Color; + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightWaterF.glsl new file mode 100755 index 0000000000..fd855aa910 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightWaterF.glsl @@ -0,0 +1,13 @@ +/** + * @file fullbrightWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void fullbright_lighting_water(); + +void main() +{ + fullbright_lighting_water(); +} diff --git a/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl b/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl index 694213219e..bdb0b05f97 100644 --- a/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl @@ -1,13 +1,13 @@ -void applyScatter(inout vec3 col); +/** + * @file shinyF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -uniform samplerCube environmentMap; +void shiny_lighting(); void main() { - vec3 ref = textureCube(environmentMap, gl_TexCoord[0].xyz).rgb; - - applyScatter(ref); - - gl_FragColor.rgb = ref; - gl_FragColor.a = gl_Color.a; + shiny_lighting(); } diff --git a/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl b/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl index 16fba0154b..c2e1ddf734 100644 --- a/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl @@ -1,27 +1,30 @@ -void default_scatter(vec3 viewVec, vec3 lightDir); +/** + * @file shinyV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void calcAtmospherics(vec3 inPositionEye); uniform vec4 origin; void main() { //transform vertex - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_Position = ftransform(); //gl_ModelViewProjectionMatrix * gl_Vertex; - vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; + vec4 pos = (gl_ModelViewMatrix * gl_Vertex); vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + + calcAtmospherics(pos.xyz); gl_FrontColor = gl_Color; - vec3 ref = reflect(pos, norm); - - vec3 d = pos - origin.xyz; - float dist = dot(normalize(d), ref); - vec3 e = d + (ref * max(origin.w-dist, 0.0)); - - ref = e - origin.xyz; + vec3 ref = reflect(pos.xyz, -norm); gl_TexCoord[0] = gl_TextureMatrix[0]*vec4(ref,1.0); - default_scatter(pos.xyz, gl_LightSource[0].position.xyz); + gl_FogFragCoord = pos.z; } diff --git a/indra/newview/app_settings/shaders/class1/objects/shinyWaterF.glsl b/indra/newview/app_settings/shaders/class1/objects/shinyWaterF.glsl new file mode 100755 index 0000000000..0a2a5f624b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/shinyWaterF.glsl @@ -0,0 +1,13 @@ +/** + * @file shinyWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void shiny_lighting_water(); + +void main() +{ + shiny_lighting_water(); +} diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl index ce5ab12b74..7dacca4fe1 100644 --- a/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl @@ -1,3 +1,10 @@ +/** + * @file simpleF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + void default_lighting(); void main() diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl index 2aa3521931..0df89c8fc3 100644 --- a/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl @@ -1,20 +1,26 @@ -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); -void default_scatter(vec3 viewVec, vec3 lightDir); +/** + * @file simpleV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -attribute vec4 materialColor; +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +void calcAtmospherics(vec3 inPositionEye); void main() { //transform vertex - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_Position = ftransform(); //gl_ModelViewProjectionMatrix * gl_Vertex; gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; - vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + vec4 pos = (gl_ModelViewMatrix * gl_Vertex); - default_scatter(pos, gl_LightSource[0].position.xyz); + vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + + calcAtmospherics(pos.xyz); - vec4 color = calcLighting(pos, norm, materialColor, gl_Color); + vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); gl_FrontColor = color; gl_FogFragCoord = pos.z; diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleWaterF.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleWaterF.glsl new file mode 100755 index 0000000000..e066b3d02f --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/objects/simpleWaterF.glsl @@ -0,0 +1,13 @@ +/** + * @file simpleWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void default_lighting_water(); + +void main() +{ + default_lighting_water(); +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl new file mode 100644 index 0000000000..248c322011 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl @@ -0,0 +1,13 @@ +/** + * @file atmosphericsF.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +vec3 atmosLighting(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl new file mode 100644 index 0000000000..c2c39e2e10 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl @@ -0,0 +1,34 @@ +/** + * @file atmosphericsHelpersV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +vec3 atmosAmbient(vec3 light) +{ + return gl_LightModel.ambient.rgb + light; +} + +vec3 atmosAffectDirectionalLight(float lightIntensity) +{ + return gl_LightSource[0].diffuse.rgb * lightIntensity; +} + +vec3 atmosGetDiffuseSunlightColor() +{ + return gl_LightSource[0].diffuse.rgb; +} + +vec3 scaleDownLight(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + +vec3 scaleUpLight(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl new file mode 100644 index 0000000000..551b643403 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl @@ -0,0 +1,15 @@ +/** + * @file atmosphericsV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void setPositionEye(vec3 v); + +void calcAtmospherics(vec3 inPositionEye) +{ + /* stub function for fallback compatibility on class1 hardware */ + setPositionEye(inPositionEye); +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl new file mode 100644 index 0000000000..c001a4070b --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl @@ -0,0 +1,13 @@ +/** + * @file atmosphericVarsF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +varying vec3 vary_PositionEye; + +vec3 getPositionEye() +{ + return vary_PositionEye; +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl new file mode 100644 index 0000000000..1b263b0854 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl @@ -0,0 +1,19 @@ +/** + * @file atmosphericVarsV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +varying vec3 vary_PositionEye; + + +vec3 getPositionEye() +{ + return vary_PositionEye; +} + +void setPositionEye(vec3 v) +{ + vary_PositionEye = v; +} diff --git a/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl new file mode 100644 index 0000000000..c1ffda1596 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/gammaF.glsl @@ -0,0 +1,19 @@ +/** + * @file gammaF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform vec4 gamma; + +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light) { + // For compatibility with lower cards. Do nothing. + return light; +} + +vec3 fullbrightScaleSoftClip(vec3 light) { + return scaleSoftClip(light); +} + diff --git a/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl new file mode 100644 index 0000000000..7097906fdd --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/transportF.glsl @@ -0,0 +1,26 @@ +/** + * @file transportF.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +vec3 atmosTransport(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + +vec3 fullbrightAtmosTransport(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + + +vec3 fullbrightShinyAtmosTransport(vec3 light) +{ + /* stub function for fallback compatibility on class1 hardware */ + return light; +} + diff --git a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl index 7957eddb31..3dd62d2d14 100644 --- a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl +++ b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl @@ -1,8 +1,12 @@ -vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol); -void default_scatter(vec3 viewVec, vec3 lightDir); +/** + * @file eyeballV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -attribute vec4 materialColor; -attribute vec4 specularColor; +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol); +void calcAtmospherics(vec3 inPositionEye); void main() { @@ -12,12 +16,15 @@ void main() vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + + calcAtmospherics(pos.xyz); - default_scatter(pos.xyz, gl_LightSource[0].position.xyz); - vec4 specular = specularColor; - vec4 color = calcLightingSpecular(pos, norm, materialColor, specular, gl_Color.rgb); + // vec4 specular = specularColor; + vec4 specular = vec4(1.0); + vec4 color = calcLightingSpecular(pos, norm, gl_Color, specular, vec4(0.0)); gl_FrontColor = color; gl_FogFragCoord = pos.z; + } diff --git a/indra/newview/app_settings/shaders/class2/effects/blurF.glsl b/indra/newview/app_settings/shaders/class2/effects/blurF.glsl new file mode 100644 index 0000000000..94433202af --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/effects/blurF.glsl @@ -0,0 +1,31 @@ +/** + * @file blurf.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2DRect RenderTexture; +uniform float bloomStrength; + +varying vec4 gl_TexCoord[gl_MaxTextureCoords]; +void main(void) +{ + float blurWeights[7]; + blurWeights[0] = 0.05; + blurWeights[1] = 0.1; + blurWeights[2] = 0.2; + blurWeights[3] = 0.3; + blurWeights[4] = 0.2; + blurWeights[5] = 0.1; + blurWeights[6] = 0.05; + + vec3 color = vec3(0,0,0); + for (int i = 0; i < 7; i++){ + color += vec3(texture2DRect(RenderTexture, gl_TexCoord[i].st)) * blurWeights[i]; + } + + color *= bloomStrength; + + gl_FragColor = vec4(color, 1.0); +} diff --git a/indra/newview/app_settings/shaders/class2/effects/blurV.glsl b/indra/newview/app_settings/shaders/class2/effects/blurV.glsl new file mode 100644 index 0000000000..ba65b16cc1 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/effects/blurV.glsl @@ -0,0 +1,35 @@ +/** + * @file blurV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform vec2 texelSize; +uniform vec2 blurDirection; +uniform float blurWidth; + +void main(void) +{ + // Transform vertex + gl_Position = ftransform(); + + vec2 blurDelta = texelSize * blurDirection * vec2(blurWidth, blurWidth); + vec2 s = gl_MultiTexCoord0.st - (blurDelta * 3.0); + + // for (int i = 0; i < 7; i++) { + // gl_TexCoord[i].st = s + (i * blurDelta); + // } + + // MANUALLY UNROLL + gl_TexCoord[0].st = s; + gl_TexCoord[1].st = s + blurDelta; + gl_TexCoord[2].st = s + (2. * blurDelta); + gl_TexCoord[3].st = s + (3. * blurDelta); + gl_TexCoord[4].st = s + (4. * blurDelta); + gl_TexCoord[5].st = s + (5. * blurDelta); + gl_TexCoord[6].st = s + (6. * blurDelta); + + // gl_TexCoord[0].st = s; + // gl_TexCoord[1].st = blurDelta; +} diff --git a/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl b/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl new file mode 100644 index 0000000000..623ef7a81a --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/effects/colorFilterF.glsl @@ -0,0 +1,31 @@ +/** + * @file colorFilterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2DRect RenderTexture; +uniform float brightness; +uniform float contrast; +uniform vec3 contrastBase; +uniform float saturation; +uniform vec3 lumWeights; + +const float gamma = 2.0; + +void main(void) +{ + vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); + + /// Modulate brightness + color *= brightness; + + /// Modulate contrast + color = mix(contrastBase, color, contrast); + + /// Modulate saturation + color = mix(vec3(dot(color, lumWeights)), color, saturation); + + gl_FragColor = vec4(color, 1.0); +} diff --git a/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl b/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl new file mode 100644 index 0000000000..29c2a0948c --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl @@ -0,0 +1,14 @@ +/** + * @file drawQuadV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void main(void) +{ + //transform vertex + gl_Position = ftransform(); + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[1] = gl_MultiTexCoord1; +} diff --git a/indra/newview/app_settings/shaders/class2/effects/extractF.glsl b/indra/newview/app_settings/shaders/class2/effects/extractF.glsl new file mode 100644 index 0000000000..a1583b13eb --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/effects/extractF.glsl @@ -0,0 +1,22 @@ +/** + * @file extractF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2DRect RenderTexture; +uniform float extractLow; +uniform float extractHigh; +uniform vec3 lumWeights; + +void main(void) +{ + /// Get scene color + vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); + + /// Extract luminance and scale up by night vision brightness + float lum = smoothstep(extractLow, extractHigh, dot(color, lumWeights)); + + gl_FragColor = vec4(vec3(lum), 1.0); +} diff --git a/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl b/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl new file mode 100644 index 0000000000..271d5cf8d6 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/effects/nightVisionF.glsl @@ -0,0 +1,42 @@ +/** + * @file nightVisionF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2DRect RenderTexture; +uniform sampler2D NoiseTexture; +uniform float brightMult; +uniform float noiseStrength; + +float luminance(vec3 color) +{ + /// CALCULATING LUMINANCE (Using NTSC lum weights) + /// http://en.wikipedia.org/wiki/Luma_%28video%29 + return dot(color, vec3(0.299, 0.587, 0.114)); +} + +void main(void) +{ + /// Get scene color + vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); + + /// Extract luminance and scale up by night vision brightness + float lum = luminance(color) * brightMult; + + /// Convert into night vision color space + /// Newer NVG colors (crisper and more saturated) + vec3 outColor = (lum * vec3(0.91, 1.21, 0.9)) + vec3(-0.07, 0.1, -0.12); + + /// Add noise + float noiseValue = texture2D(NoiseTexture, gl_TexCoord[1].st).r; + noiseValue = (noiseValue - 0.5) * noiseStrength; + + /// Older NVG colors (more muted) + // vec3 outColor = (lum * vec3(0.82, 0.75, 0.83)) + vec3(0.05, 0.32, -0.11); + + outColor += noiseValue; + + gl_FragColor = vec4(outColor, 1.0); +} diff --git a/indra/newview/app_settings/shaders/class2/effects/simpleF.glsl b/indra/newview/app_settings/shaders/class2/effects/simpleF.glsl new file mode 100644 index 0000000000..e55d278b81 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/effects/simpleF.glsl @@ -0,0 +1,14 @@ +/** + * @file simpleF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2DRect RenderTexture; + +void main(void) +{ + vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st)); + gl_FragColor = vec4(1.0 - color, 1.0); +} diff --git a/indra/newview/app_settings/shaders/class2/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class2/environment/terrainF.glsl new file mode 100644 index 0000000000..4253bc21c3 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/environment/terrainF.glsl @@ -0,0 +1,38 @@ +/** + * @file terrainF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D detail_0; +uniform sampler2D detail_1; +uniform sampler2D detail_2; +uniform sampler2D detail_3; +uniform sampler2D alpha_ramp; + +vec3 atmosLighting(vec3 light); + +vec3 scaleSoftClip(vec3 color); + +void main() +{ + /// Note: This should duplicate the blending functionality currently used for the terrain rendering. + + /// TODO Confirm tex coords and bind them appropriately in vert shader. + vec4 color0 = texture2D(detail_0, gl_TexCoord[0].xy); + vec4 color1 = texture2D(detail_1, gl_TexCoord[0].xy); + vec4 color2 = texture2D(detail_2, gl_TexCoord[0].xy); + vec4 color3 = texture2D(detail_3, gl_TexCoord[0].xy); + + float alpha1 = texture2D(alpha_ramp, gl_TexCoord[0].zw).a; + float alpha2 = texture2D(alpha_ramp,gl_TexCoord[1].xy).a; + float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a; + vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); + + /// Add WL Components + outColor.rgb = atmosLighting(outColor.rgb * gl_Color.rgb); + + gl_FragColor = vec4(scaleSoftClip(outColor.rgb), 1.0); +} + diff --git a/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl new file mode 100644 index 0000000000..119d55a2cd --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl @@ -0,0 +1,52 @@ +/** + * @file terrainV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +void calcAtmospherics(vec3 inPositionEye); + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); + +vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) +{ + vec4 tcoord; + + tcoord.x = dot(vpos, tp0); + tcoord.y = dot(vpos, tp1); + tcoord.z = tc.z; + tcoord.w = tc.w; + + tcoord = mat * tcoord; + + return tcoord; +} + +void main() +{ + //transform vertex + gl_Position = ftransform(); + + vec4 pos = gl_ModelViewMatrix * gl_Vertex; + vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + + /// Potentially better without it for water. + pos /= pos.w; + + calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz); + + vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0)); + + gl_FrontColor = color; + + // Transform and pass tex coords + gl_TexCoord[0].xy = texgen_object(gl_Vertex, gl_MultiTexCoord0, gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy; + + vec4 t = gl_MultiTexCoord1; + + gl_TexCoord[0].zw = t.xy; + gl_TexCoord[1].xy = t.xy-vec2(2.0, 0.0); + gl_TexCoord[1].zw = t.xy-vec2(1.0, 0.0); +} + diff --git a/indra/newview/app_settings/shaders/class2/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class2/environment/terrainWaterF.glsl new file mode 100755 index 0000000000..3a98970f8c --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/environment/terrainWaterF.glsl @@ -0,0 +1,39 @@ +/** + * @file terrainWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D detail_0; +uniform sampler2D detail_1; +uniform sampler2D detail_2; +uniform sampler2D detail_3; +uniform sampler2D alpha_ramp; + +vec3 atmosLighting(vec3 light); + +vec4 applyWaterFog(vec4 color); + +void main() +{ + /// Note: This should duplicate the blending functionality currently used for the terrain rendering. + + /// TODO Confirm tex coords and bind them appropriately in vert shader. + vec4 color0 = texture2D(detail_0, gl_TexCoord[0].xy); + vec4 color1 = texture2D(detail_1, gl_TexCoord[0].xy); + vec4 color2 = texture2D(detail_2, gl_TexCoord[0].xy); + vec4 color3 = texture2D(detail_3, gl_TexCoord[0].xy); + + float alpha1 = texture2D(alpha_ramp, gl_TexCoord[0].zw).a; + float alpha2 = texture2D(alpha_ramp,gl_TexCoord[1].xy).a; + float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a; + vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); + + /// Add WL Components + outColor.rgb = atmosLighting(outColor.rgb * gl_Color.rgb); + + outColor = applyWaterFog(outColor); + gl_FragColor = outColor; +} + diff --git a/indra/newview/app_settings/shaders/class2/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class2/environment/underWaterF.glsl new file mode 100644 index 0000000000..1998fea227 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/environment/underWaterF.glsl @@ -0,0 +1,88 @@ +/** + * @file underWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; +uniform sampler2D bumpMap; +uniform sampler2D screenTex; +uniform sampler2D refTex; +uniform sampler2D screenDepth; + +uniform vec4 fogCol; +uniform vec3 lightDir; +uniform vec3 specular; +uniform float lightExp; +uniform vec2 fbScale; +uniform float refScale; +uniform float znear; +uniform float zfar; +uniform float kd; +uniform vec4 waterPlane; +uniform vec3 eyeVec; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; +uniform vec2 screenRes; + +//bigWave is (refCoord.w, view.w); +varying vec4 refCoord; +varying vec4 littleWave; +varying vec4 view; + +vec4 applyWaterFog(vec4 color, vec3 viewVec) +{ + //normalize view vector + vec3 view = normalize(viewVec); + float es = -view.z; + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + //get object depth + float depth = length(viewVec); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + //return vec4(1.0, 0.0, 1.0, 1.0); + return color * D + kc * L; + //depth /= 10.0; + //return vec4(depth,depth,depth,0.0); +} + +void main() +{ + vec4 color; + + //get detail normals + vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + vec3 wavef = normalize(wave1+wave2+wave3); + + //figure out distortion vector (ripply) + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + distort = distort+wavef.xy*refScale; + + vec4 fb = texture2D(screenTex, distort); + + gl_FragColor = applyWaterFog(fb,view.xyz); +} diff --git a/indra/newview/app_settings/shaders/class2/environment/waterF.glsl b/indra/newview/app_settings/shaders/class2/environment/waterF.glsl index 11a057b177..8f3d11badc 100644 --- a/indra/newview/app_settings/shaders/class2/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class2/environment/waterF.glsl @@ -1,138 +1,117 @@ -void applyScatter(inout vec3 color); +/** + * @file waterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +vec3 scaleSoftClip(vec3 inColor); +vec3 atmosTransport(vec3 inColor); -uniform sampler2D diffuseMap; uniform sampler2D bumpMap; -uniform samplerCube environmentMap; //: TEXUNIT4, // Environment map texture -uniform sampler2D screenTex; // : TEXUNIT5 +uniform sampler2D screenTex; +uniform sampler2D refTex; +uniform float sunAngle; +uniform float sunAngle2; uniform vec3 lightDir; uniform vec3 specular; uniform float lightExp; -uniform vec2 fbScale; uniform float refScale; +uniform float kd; +uniform vec2 screenRes; +uniform vec3 normScale; +uniform float fresnelScale; +uniform float fresnelOffset; +uniform float blurMultiplier; -float msin(float x) { - float k = sin(x)+1.0; - k *= 0.5; - k *= k; - return 2.0 * k; -} -float mcos(float x) { - float k = cos(x)+1.0; - k *= 0.5; - k *= k; - return 2.0 * k; -} +//bigWave is (refCoord.w, view.w); +varying vec4 refCoord; +varying vec4 littleWave; +varying vec4 view; -float waveS(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap) +void main() { - return texture1D(sinMap, (dot(d, v)*f + t*s)*f).r*a; -} + vec4 color; + + float dist = length(view.xy); + + //normalize view vector + vec3 viewVec = normalize(view.xyz); + + //get wave normals + vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0; + vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0; + vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0; + //get base fresnel components + + vec3 df = vec3( + dot(viewVec, wave1), + dot(viewVec, wave2), + dot(viewVec, wave3) + ) * fresnelScale + fresnelOffset; + df *= df; + + vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5; + + float dist2 = dist; + dist = max(dist, 5.0); + + float dmod = sqrt(dist); + + vec2 dmod_scale = vec2(dmod*dmod, dmod); + + //get reflected color + vec2 refdistort1 = wave1.xy*normScale.x; + vec2 refvec1 = distort+refdistort1/dmod_scale; + vec4 refcol1 = texture2D(refTex, refvec1); + + vec2 refdistort2 = wave2.xy*normScale.y; + vec2 refvec2 = distort+refdistort2/dmod_scale; + vec4 refcol2 = texture2D(refTex, refvec2); + + vec2 refdistort3 = wave3.xy*normScale.z; + vec2 refvec3 = distort+refdistort3/dmod_scale; + vec4 refcol3 = texture2D(refTex, refvec3); -float waveC(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap) -{ - return texture1D(sinMap, (dot(d, v)*f + t*s)*f).g*a*2.0-1.0; -} + vec4 refcol = refcol1 + refcol2 + refcol3; + float df1 = df.x + df.y + df.z; + refcol *= df1 * 0.333; + + vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5; + + wavef.z *= max(-viewVec.z, 0.1); + wavef = normalize(wavef); + + float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset; + + vec2 refdistort4 = wavef.xy*0.125; + refdistort4.y -= abs(refdistort4.y); + vec2 refvec4 = distort+refdistort4/dmod; + float dweight = min(dist2*blurMultiplier, 1.0); + vec4 baseCol = texture2D(refTex, refvec4); + refcol = mix(baseCol*df2, refcol, dweight); -float magnitude(vec3 vec) { - return sqrt(dot(vec,vec)); -} - -vec3 mreflect(vec3 i, vec3 n) { - return i + n * 2.0 * abs(dot(n,i))+vec3(0.0,0.0,0.5); -} - -void main() -{ - vec2 texCoord = gl_TexCoord[0].xy; // Texture coordinates - vec2 littleWave1 = gl_TexCoord[0].zw; - vec2 littleWave2 = gl_TexCoord[1].xy; - vec2 bigWave = gl_TexCoord[1].zw; - vec3 viewVec = gl_TexCoord[2].xyz; - vec4 refCoord = gl_TexCoord[3]; - vec4 col = gl_Color; - vec4 color; - - //get color from alpha map (alpha denotes water depth), rgb denotes water color - vec4 wcol = texture2D(diffuseMap, texCoord.xy); - - //store texture alpha - float da = wcol.a; - - //modulate by incoming water color - //wcol.a *= refCoord.w; - - //scale wcol.a (water depth) for steep transition - wcol.a *= wcol.a; - - //normalize view vector - viewVec = normalize(viewVec); - - //get bigwave normal - vec3 wavef = texture2D(bumpMap, bigWave).xyz*2.0; - - vec3 view = vec3(viewVec.x, viewVec.y, viewVec.z); - - float dx = 1.0-(dot(wavef*2.0-vec3(1.0), view))*da; - dx *= 0.274; - - //get detail normals - vec3 dcol = texture2D(bumpMap, littleWave1+dx*view.xy).rgb*0.75; - dcol += texture2D(bumpMap, littleWave2+view.xy*dx*0.1).rgb*1.25; - - //interpolate between big waves and little waves (big waves in deep water) - wavef = wavef*wcol.a + dcol*(1.0-wcol.a); - - //crunch normal to range [-1,1] - wavef -= vec3(1,1,1); - - //get base fresnel component - float df = dot(viewVec,wavef); - //reposition fresnel to latter half of [0,1] - df = 1.0-clamp(df,0.0,1.0); + //get specular component + float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); + + //harden specular + spec = pow(spec, 128.0); - //set output alpha based on fresnel - color.a = clamp((df+da)*0.5,0.0,1.0); - - //calculate reflection vector - vec3 ref = reflect(viewVec.xyz, wavef); - - //get specular component - float spec = clamp(dot(lightDir, normalize(ref)),0.0,1.0); - - //fudge reflection to be more noisy at good angles - ref.z = ref.z*ref.z+df*df*0.5; - - //get diffuse component - float diff = clamp((abs(dot(ref, wavef))),0.0,1.0)*0.9; - - //fudge diffuse for extra contrast and ambience - diff *= diff; - diff += 0.4; - - //set diffuse color contribution - color.rgb = textureCube(environmentMap, ref).rgb*diff; - - //harden specular - spec = pow(spec, lightExp); - - //add specular color contribution - color.rgb += spec * specular; + //figure out distortion vector (ripply) + vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0); + + vec4 fb = texture2D(screenTex, distort2); + + //mix with reflection + // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug + color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999); + color.rgb += spec * specular; + + color.rgb = atmosTransport(color.rgb); + color.rgb = scaleSoftClip(color.rgb); + color.a = spec * sunAngle2; - //figure out distortion vector (ripply) - vec2 distort = clamp(((refCoord.xy/refCoord.z) * 0.5 + 0.5 + wavef.xy*refScale),0.0,0.99); - - //read from framebuffer (offset) - vec4 fb = texture2D(screenTex, distort*fbScale); - - //tint by framebuffer - color.rgb = color.a*color.rgb + (1.0-color.a)*fb.rgb; - - //apply fog - applyScatter(color.rgb); - - color.a = spec*0.5+fb.a; - - gl_FragColor = color; + gl_FragColor = color; } diff --git a/indra/newview/app_settings/shaders/class2/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class2/environment/waterFogF.glsl new file mode 100644 index 0000000000..522c990cf8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/environment/waterFogF.glsl @@ -0,0 +1,54 @@ +/** + * @file waterFogF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform vec4 lightnorm; +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec3 getPositionEye(); + +vec4 applyWaterFog(vec4 color) +{ + //normalize view vector + vec3 view = normalize(getPositionEye()); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(getPositionEye() - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl index 6f732ed731..b372d66298 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl @@ -1,36 +1,23 @@ -void applyScatter(inout vec3 color); +/** + * @file lightF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ uniform sampler2D diffuseMap; +vec3 atmosLighting(vec3 light); +vec3 scaleSoftClip(vec3 light); + void default_lighting() { - vec4 color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); - //applyScatter(color.rgb); - gl_FragColor = color; -} + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + + color.rgb = atmosLighting(color.rgb); -void alpha_lighting() -{ - vec4 diff = texture2D(diffuseMap, gl_TexCoord[0].xy); - vec3 color = gl_Color.rgb * diff.rgb; - applyScatter(color); - gl_FragColor.rgb = color; - gl_FragColor.a = diff.a * gl_Color.a; -} + color.rgb = scaleSoftClip(color.rgb); -void water_lighting(inout vec3 diff) -{ - diff = (diff*0.9 + gl_Color.rgb*0.1); - applyScatter(diff); -} - -void terrain_lighting(inout vec3 color) -{ - color.rgb *= gl_Color.rgb; - applyScatter(color); + gl_FragColor = color; } -vec4 getLightColor() -{ - return gl_Color; -} \ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightF.glsl new file mode 100644 index 0000000000..e6b6d85808 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightF.glsl @@ -0,0 +1,23 @@ +/** + * @file lightFullbrightF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; + +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +void fullbright_lighting() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + + color.rgb = fullbrightAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyF.glsl new file mode 100644 index 0000000000..8f408c0436 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightShinyF.glsl @@ -0,0 +1,30 @@ +/** + * @file lightFullbrightShinyF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; +uniform samplerCube environmentMap; + +vec3 fullbrightShinyAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + +void fullbright_shiny_lighting() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy); + color.rgb *= gl_Color.rgb; + + vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, gl_Color.a); + + color.rgb = fullbrightShinyAtmosTransport(color.rgb); + + color.rgb = fullbrightScaleSoftClip(color.rgb); + + color.a = max(color.a, gl_Color.a); + + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterF.glsl new file mode 100644 index 0000000000..060ad9cb67 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightFullbrightWaterF.glsl @@ -0,0 +1,21 @@ +/** + * @file lightFullbrightWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; + +vec3 fullbrightAtmosTransport(vec3 light); +vec4 applyWaterFog(vec4 color); + +void fullbright_lighting_water() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + + color.rgb = fullbrightAtmosTransport(color.rgb); + + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightShinyF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightShinyF.glsl new file mode 100644 index 0000000000..b3927c77a6 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightShinyF.glsl @@ -0,0 +1,29 @@ +/** + * @file lightShinyF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; +uniform samplerCube environmentMap; + +vec3 scaleSoftClip(vec3 light); +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void shiny_lighting() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy); + color.rgb *= gl_Color.rgb; + + vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, gl_Color.a); + + color.rgb = atmosLighting(color.rgb); + + color.rgb = scaleSoftClip(color.rgb); + color.a = max(color.a, gl_Color.a); + gl_FragColor = color; +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterF.glsl new file mode 100644 index 0000000000..f090306be6 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightShinyWaterF.glsl @@ -0,0 +1,27 @@ +/** + * @file lightShinyWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + + +uniform sampler2D diffuseMap; +uniform samplerCube environmentMap; + +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void shiny_lighting_water() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy); + color.rgb *= gl_Color.rgb; + + vec3 envColor = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb; + color.rgb = mix(color.rgb, envColor.rgb, gl_Color.a); + + color.rgb = atmosLighting(color.rgb); + color.a = max(color.a, gl_Color.a); + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightSpecularV.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightSpecularV.glsl new file mode 100644 index 0000000000..c3384ffc5d --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightSpecularV.glsl @@ -0,0 +1,16 @@ +/** + * @file lightSpecularV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +// All lights, no specular highlights + +vec4 sumLightsSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol); + +vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol) +{ + return sumLightsSpecular(pos, norm, color, specularColor, baseCol); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl index b15960dea2..ff3bcb5cd2 100644 --- a/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl @@ -1,126 +1,16 @@ -// All lights, no specular highlights - -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; -} +/** + * @file lightV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l) -{ - return pow(max(dot(reflect(view, n),l), 0.0),8.0); -} +// All lights, no specular highlights -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(1.0/(r * d), 0.0, 1.0); - - //angular attenuation - - da *= calcDirectionalLightSpecular(specular, view, n, lv, lightCol, da); - - return da*lightCol; -} +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 = gl_LightModel.ambient.rgb + baseLight.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 += gl_LightSource[2].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation); - col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation); - col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation); - col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation); - col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation); - col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation); - - col.rgb = min(col.rgb*color.rgb, 1.0); - - gl_FrontColor = vec4(col.rgb, col.a); - 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)); + return sumLights(pos, norm, color, baseLight); } -vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol) -{ - vec4 col; - col.a = color.a; - - col.rgb = gl_LightModel.ambient.rgb; - - vec3 view = normalize(pos); - - vec4 specular = specularColor; - specularColor.rgb = vec3(0.0, 0.0, 0.0); - - col.rgb += baseCol.a*gl_LightSource[0].diffuse.rgb*calcDirectionalLightSpecular(specularColor, view, norm, gl_LightSource[0].position.xyz,gl_LightSource[0].diffuse.rgb*baseCol.a, 1.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 += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[2].position.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation,gl_LightSource[2].diffuse.rgb); - col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[3].position.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].quadraticAttenuation,gl_LightSource[3].diffuse.rgb); - col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[4].position.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].quadraticAttenuation,gl_LightSource[4].diffuse.rgb); - col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[5].position.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].quadraticAttenuation,gl_LightSource[5].diffuse.rgb); - //col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[6].position.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation,gl_LightSource[6].diffuse.rgb); - //col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[7].position.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation,gl_LightSource[7].diffuse.rgb); - col.rgb += baseCol.rgb; - - col.rgb = min(col.rgb*color.rgb, 1.0); - specularColor.rgb = min(specularColor.rgb*specular.rgb, 1.0); - - gl_FrontColor = vec4(col.rgb+specularColor.rgb,col.a); - return col; -} - -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/class2/lighting/lightWaterF.glsl b/indra/newview/app_settings/shaders/class2/lighting/lightWaterF.glsl new file mode 100644 index 0000000000..086954cd47 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/lightWaterF.glsl @@ -0,0 +1,21 @@ +/** + * @file lightWaterF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform sampler2D diffuseMap; + +vec3 atmosLighting(vec3 light); +vec4 applyWaterFog(vec4 color); + +void default_lighting_water() +{ + vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * gl_Color; + + color.rgb = atmosLighting(color.rgb); + + gl_FragColor = applyWaterFog(color); +} + diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl new file mode 100644 index 0000000000..edd1a8a946 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl @@ -0,0 +1,41 @@ +/** + * @file sumLightsV.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 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol); + +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 = vec4(0.0, 0.0, 0.0, color.a); + + vec3 view = normalize(pos); + + /// collect all the specular values from each calcXXXLightSpecular() function + vec4 specularSum = vec4(0.0); + + // Collect normal lights (need to be divided by two, as we later multiply by 2) + 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 += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[2].position.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].diffuse.rgb); + col.rgb += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[3].position.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].quadraticAttenuation, gl_LightSource[3].diffuse.rgb); + //col.rgb += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[4].position.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].quadraticAttenuation, gl_LightSource[4].diffuse.rgb); + col.rgb = scaleDownLight(col.rgb); + + // Add windlight lights + 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/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl new file mode 100644 index 0000000000..f4c59734a4 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl @@ -0,0 +1,34 @@ +/** + * @file sumLightsV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +float calcDirectionalLight(vec3 n, vec3 l); +float calcPointLight(vec3 v, vec3 n, vec4 lp, float la); + +vec3 atmosAmbient(vec3 light); +vec3 atmosAffectDirectionalLight(float lightIntensity); +vec3 scaleDownLight(vec3 light); + +vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) +{ + vec4 col = vec4(0.0, 0.0, 0.0, color.a); + + // Collect normal lights (need to be divided by two, as we later multiply by 2) + col.rgb += gl_LightSource[1].diffuse.rgb * calcDirectionalLight(norm, gl_LightSource[1].position.xyz); + col.rgb += gl_LightSource[2].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation); + col.rgb += gl_LightSource[3].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation); + //col.rgb += gl_LightSource[4].diffuse.rgb * calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation); + col.rgb = scaleDownLight(col.rgb); + + // Add windlight lights + 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; +} + diff --git a/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl b/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl new file mode 100755 index 0000000000..0d52f32a2e --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl @@ -0,0 +1,31 @@ +/** + * @file shinyV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); + +void calcAtmospherics(vec3 inPositionEye); + +uniform vec4 origin; + +void main() +{ + //transform vertex + gl_Position = ftransform(); + + vec4 pos = (gl_ModelViewMatrix * gl_Vertex); + vec3 norm = normalize(gl_NormalMatrix * gl_Normal); + vec3 ref = reflect(pos.xyz, -norm); + + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0); + + calcAtmospherics(pos.xyz); + + gl_FrontColor = calcLighting(pos.xyz, norm, gl_Color, vec4(0.0)); + + gl_FogFragCoord = pos.z; +} diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl new file mode 100644 index 0000000000..92c0664a5e --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -0,0 +1,24 @@ +/** + * @file atmosphericsF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +////////////////////////////////////////////////////////// +// The fragment shader for the terrain atmospherics +////////////////////////////////////////////////////////// + +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); + +uniform sampler2D cloudMap; +uniform vec4 cloud_pos_density1; + +vec3 atmosLighting(vec3 light) +{ + light *= getAtmosAttenuation().r; + light += getAdditiveColor(); + return (2.0 * light); +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl new file mode 100644 index 0000000000..32d5ed5db2 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsHelpersV.glsl @@ -0,0 +1,41 @@ +/** + * @file atmosphericsHelpersV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +// Output variables +vec3 getSunlitColor(); +vec3 getAmblitColor(); +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); +vec3 getPositionEye(); + +uniform float scene_light_strength; + +vec3 atmosAmbient(vec3 light) +{ + return getAmblitColor() + light / 2.0; +} + +vec3 atmosAffectDirectionalLight(float lightIntensity) +{ + return getSunlitColor() * lightIntensity; +} + +vec3 atmosGetDiffuseSunlightColor() +{ + return getSunlitColor(); +} + +vec3 scaleDownLight(vec3 light) +{ + return (light / scene_light_strength ); +} + +vec3 scaleUpLight(vec3 light) +{ + return (light * scene_light_strength); +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl new file mode 100644 index 0000000000..e40372e819 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl @@ -0,0 +1,137 @@ +/** + * @file atmosphericsV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +// varying param funcs +void setSunlitColor(vec3 v); +void setAmblitColor(vec3 v); +void setAdditiveColor(vec3 v); +void setAtmosAttenuation(vec3 v); +void setPositionEye(vec3 v); + +vec3 getAdditiveColor(); + +//varying vec4 vary_CloudUVs; +//varying float vary_CloudDensity; + +// Inputs +uniform vec4 morphFactor; +uniform vec3 camPosLocal; +//uniform vec4 camPosWorld; + +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform vec4 haze_horizon; +uniform vec4 haze_density; +uniform vec4 cloud_shadow; +uniform vec4 density_multiplier; +uniform vec4 distance_multiplier; +uniform vec4 max_y; +uniform vec4 glow; + +void calcAtmospherics(vec3 inPositionEye) { + + vec3 P = inPositionEye; + setPositionEye(P); + + //(TERRAIN) limit altitude + if (P.y > max_y.x) P *= (max_y.x / P.y); + if (P.y < -max_y.x) P *= (-max_y.x / P.y); + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = sunlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density * 1.0 + vec4(haze_density.r) * 0.25) * (density_multiplier.x * max_y.x); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density.r); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density.r) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier.x; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier.x); + + //final atmosphere attenuation factor + setAtmosAttenuation(temp1.rgb); + //vary_AtmosAttenuation = distance_multiplier / 10000.; + //vary_AtmosAttenuation = density_multiplier * 100.; + //vary_AtmosAttenuation = vec4(Plen / 100000., 0., 0., 1.); + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .03); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + //add "minimum anti-solar illumination" + temp2.x += .25; + + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5; + + //haze color + setAdditiveColor( + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow.x) + tmpAmbient) + + (haze_horizon.r * haze_weight) * (sunlight*(1.-cloud_shadow.x) * temp2.x + + tmpAmbient))); + + //brightness of surface both sunlight and ambient + setSunlitColor(vec3(sunlight * .5)); + setAmblitColor(vec3(tmpAmbient * .25)); + setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); + + // vary_SunlitColor = vec3(0); + // vary_AmblitColor = vec3(0); + // vary_AdditiveColor = vec4(Pn, 1.0); + + /* + const float cloudShadowScale = 100.; + // Get cloud uvs for shadowing + vec3 cloudPos = inPositionEye + camPosWorld - cloudShadowScale / 2.; + vary_CloudUVs.xy = cloudPos.xz / cloudShadowScale; + + // We can take uv1 and multiply it by (TerrainSpan / CloudSpan) +// cloudUVs *= (((worldMaxZ - worldMinZ) * 20) /40000.); + vary_CloudUVs *= (10000./40000.); + + // Offset by sun vector * (CloudAltitude / CloudSpan) + vary_CloudUVs.x += tmpLightnorm.x / tmpLightnorm.y * (3000./40000.); + vary_CloudUVs.y += tmpLightnorm.z / tmpLightnorm.y * (3000./40000.); + */ +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl new file mode 100644 index 0000000000..0dbf2d35e7 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsF.glsl @@ -0,0 +1,34 @@ +/** + * @file atmosphericVars.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +varying vec3 vary_PositionEye; + +varying vec3 vary_SunlitColor; +varying vec3 vary_AmblitColor; +varying vec3 vary_AdditiveColor; +varying vec3 vary_AtmosAttenuation; + +vec3 getPositionEye() +{ + return vary_PositionEye; +} +vec3 getSunlitColor() +{ + return vary_SunlitColor; +} +vec3 getAmblitColor() +{ + return vary_AmblitColor; +} +vec3 getAdditiveColor() +{ + return vary_AdditiveColor; +} +vec3 getAtmosAttenuation() +{ + return vary_AtmosAttenuation; +} diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl new file mode 100644 index 0000000000..b528837a5f --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsVarsV.glsl @@ -0,0 +1,60 @@ +/** + * @file atmosphericVars.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +varying vec3 vary_PositionEye; + +varying vec3 vary_SunlitColor; +varying vec3 vary_AmblitColor; +varying vec3 vary_AdditiveColor; +varying vec3 vary_AtmosAttenuation; + +vec3 getPositionEye() +{ + return vary_PositionEye; +} +vec3 getSunlitColor() +{ + return vary_SunlitColor; +} +vec3 getAmblitColor() +{ + return vary_AmblitColor; +} +vec3 getAdditiveColor() +{ + return vary_AdditiveColor; +} +vec3 getAtmosAttenuation() +{ + return vary_AtmosAttenuation; +} + + +void setPositionEye(vec3 v) +{ + vary_PositionEye = v; +} + +void setSunlitColor(vec3 v) +{ + vary_SunlitColor = v; +} + +void setAmblitColor(vec3 v) +{ + vary_AmblitColor = v; +} + +void setAdditiveColor(vec3 v) +{ + vary_AdditiveColor = v; +} + +void setAtmosAttenuation(vec3 v) +{ + vary_AtmosAttenuation = v; +} diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl new file mode 100644 index 0000000000..b7d7e5a2c2 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -0,0 +1,76 @@ +/** + * @file WLCloudsF.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +///////////////////////////////////////////////////////////////////////// +// The fragment shader for the sky +///////////////////////////////////////////////////////////////////////// + +varying vec4 vary_CloudColorSun; +varying vec4 vary_CloudColorAmbient; +varying float vary_CloudDensity; + +uniform sampler2D cloud_noise_texture; +uniform vec4 cloud_pos_density1; +uniform vec4 cloud_pos_density2; +uniform vec4 gamma; + +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light) { + //soft clip effect: + light = 1. - clamp(light, vec3(0.), vec3(1.)); + light = 1. - pow(light, gamma.xxx); + + return light; +} + +void main() +{ + // Set variables + vec2 uv1 = gl_TexCoord[0].xy; + vec2 uv2 = gl_TexCoord[1].xy; + + vec4 cloudColorSun = vary_CloudColorSun; + vec4 cloudColorAmbient = vary_CloudColorAmbient; + float cloudDensity = vary_CloudDensity; + vec2 uv3 = gl_TexCoord[2].xy; + vec2 uv4 = gl_TexCoord[3].xy; + + // Offset texture coords + uv1 += cloud_pos_density1.xy; //large texture, visible density + uv2 += cloud_pos_density1.xy; //large texture, self shadow + uv3 += cloud_pos_density2.xy; //small texture, visible density + uv4 += cloud_pos_density2.xy; //small texture, self shadow + + + // Compute alpha1, the main cloud opacity + float alpha1 = (texture2D(cloud_noise_texture, uv1).x - 0.5) + (texture2D(cloud_noise_texture, uv3).x - 0.5) * cloud_pos_density2.z; + alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.); + + // And smooth + alpha1 = 1. - alpha1 * alpha1; + alpha1 = 1. - alpha1 * alpha1; + + + // Compute alpha2, for self shadowing effect + // (1 - alpha2) will later be used as percentage of incoming sunlight + float alpha2 = (texture2D(cloud_noise_texture, uv2).x - 0.5); + alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.); + + // And smooth + alpha2 = 1. - alpha2; + alpha2 = 1. - alpha2 * alpha2; + + // Combine + vec4 color; + color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); + color *= 2.; + + /// Gamma correct for WL (soft clip effect). + gl_FragColor.rgb = scaleSoftClip(color.rgb); + gl_FragColor.a = alpha1; +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl new file mode 100644 index 0000000000..e149d5861f --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -0,0 +1,163 @@ +/** + * @file WLCloudsV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +////////////////////////////////////////////////////////////////////////// +// The vertex shader for creating the atmospheric sky +/////////////////////////////////////////////////////////////////////////////// + +// Output parameters +varying vec4 vary_CloudColorSun; +varying vec4 vary_CloudColorAmbient; +varying float vary_CloudDensity; + +// Inputs +uniform vec3 camPosLocal; + +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform vec4 haze_horizon; +uniform vec4 haze_density; + +uniform vec4 cloud_shadow; +uniform vec4 density_multiplier; +uniform vec4 max_y; + +uniform vec4 glow; + +uniform vec4 cloud_color; + +uniform vec4 cloud_scale; + +void main() +{ + + // World / view / projection + gl_Position = ftransform(); + + gl_TexCoord[0] = gl_MultiTexCoord0; + + // Get relative position + vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0); + + // Set altitude + if (P.y > 0.) + { + P *= (max_y.x / P.y); + } + else + { + P *= (-32000. / P.y); + } + + // Can normalize then + vec3 Pn = normalize(P); + float Plen = length(P); + + // Initialize temp variables + vec4 temp1 = vec4(0.); + vec4 temp2 = vec4(0.); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = sunlight_color; + vec4 light_atten; + + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + light_atten = (blue_density * 1.0 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x); + + // Calculate relative weights + temp1 = blue_density + haze_density.x; + blue_weight = blue_density / temp1; + haze_weight = haze_density.x / temp1; + + // Compute sunlight from P & lightnorm (for long rays like sky) + temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Distance + temp2.z = Plen * density_multiplier.x; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z); + + + // Compute haze glow + temp2.x = dot(Pn, lightnorm.xyz); + temp2.x = 1. - temp2.x; + // temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .001); + // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + // Add "minimum anti-solar illumination" + temp2.x += .25; + + // Increase ambient when there are more clouds + vec4 tmpAmbient = ambient; + tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5; + + // Dim sunlight by cloud shadow percentage + sunlight *= (1. - cloud_shadow.x); + + // Haze color below cloud + vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient) + + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient) + ); + + // CLOUDS + + sunlight = sunlight_color; + temp2.y = max(0., lightnorm.y * 2.); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Cloud color out + vary_CloudColorSun = (sunlight * temp2.x) * cloud_color; + vary_CloudColorAmbient = tmpAmbient * cloud_color; + + // Attenuate cloud color by atmosphere + temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds + vary_CloudColorSun *= temp1; + vary_CloudColorAmbient *= temp1; + vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - temp1); + + // Make a nice cloud density based on the cloud_shadow value that was passed in. + vary_CloudDensity = 2. * (cloud_shadow.x - 0.25); + + + // Texture coords + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[0].xy -= 0.5; + gl_TexCoord[0].xy /= cloud_scale.x; + gl_TexCoord[0].xy += 0.5; + + gl_TexCoord[1] = gl_TexCoord[0]; + gl_TexCoord[1].x += lightnorm.x * 0.0125; + gl_TexCoord[1].y += lightnorm.z * 0.0125; + + gl_TexCoord[2] = gl_TexCoord[0] * 16.; + gl_TexCoord[3] = gl_TexCoord[1] * 16.; + + // Combine these to minimize register use + vary_CloudColorAmbient += oHazeColorBelowCloud; + + // needs this to compile on mac + //vary_AtmosAttenuation = vec3(0.0,0.0,0.0); + + // END CLOUDS +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl new file mode 100644 index 0000000000..5410889ed8 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/gammaF.glsl @@ -0,0 +1,24 @@ +/** + * @file gammaF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +uniform vec4 gamma; + +vec3 getAtmosAttenuation(); + +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light) { + //soft clip effect: + light = 1. - clamp(light, vec3(0.), vec3(1.)); + light = 1. - pow(light, gamma.xxx); + + return light; +} + +vec3 fullbrightScaleSoftClip(vec3 light) { + return mix(scaleSoftClip(light.rgb), light.rgb, getAtmosAttenuation()); +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl new file mode 100644 index 0000000000..bc6d6d33ff --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl @@ -0,0 +1,41 @@ +/** + * @file WLSkyF.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +///////////////////////////////////////////////////////////////////////// +// The fragment shader for the sky +///////////////////////////////////////////////////////////////////////// + +varying vec4 vary_HazeColor; + +uniform sampler2D cloud_noise_texture; +uniform vec4 gamma; + +/// Soft clips the light with a gamma correction +vec3 scaleSoftClip(vec3 light) { + //soft clip effect: + light = 1. - clamp(light, vec3(0.), vec3(1.)); + light = 1. - pow(light, gamma.xxx); + + return light; +} + +void main() +{ + // Potential Fill-rate optimization. Add cloud calculation + // back in and output alpha of 0 (so that alpha culling kills + // the fragment) if the sky wouldn't show up because the clouds + // are fully opaque. + + vec4 color; + color = vary_HazeColor; + color *= 2.; + + /// Gamma correct for WL (soft clip effect). + gl_FragColor.rgb = scaleSoftClip(color.rgb); + gl_FragColor.a = 1.0; +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl new file mode 100644 index 0000000000..e396aea6c9 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl @@ -0,0 +1,138 @@ +/** + * @file WLSkyV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +// SKY //////////////////////////////////////////////////////////////////////// +// The vertex shader for creating the atmospheric sky +/////////////////////////////////////////////////////////////////////////////// + +// Output parameters +varying vec4 vary_HazeColor; + +// Inputs +uniform vec3 camPosLocal; + +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 ambient; +uniform vec4 blue_horizon; +uniform vec4 blue_density; +uniform vec4 haze_horizon; +uniform vec4 haze_density; + +uniform vec4 cloud_shadow; +uniform vec4 density_multiplier; +uniform vec4 max_y; + +uniform vec4 glow; + +uniform vec4 cloud_color; + +uniform vec4 cloud_scale; + +void main() +{ + + // World / view / projection + gl_Position = ftransform(); + gl_TexCoord[0] = gl_MultiTexCoord0; + + // Get relative position + vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0); + //vec3 P = gl_Vertex.xyz + vec3(0,50,0); + + // Set altitude + if (P.y > 0.) + { + P *= (max_y.x / P.y); + } + else + { + P *= (-32000. / P.y); + } + + // Can normalize then + vec3 Pn = normalize(P); + float Plen = length(P); + + // Initialize temp variables + vec4 temp1 = vec4(0.); + vec4 temp2 = vec4(0.); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = sunlight_color; + vec4 light_atten; + + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + light_atten = (blue_density * 1.0 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x); + + // Calculate relative weights + temp1 = blue_density + haze_density.x; + blue_weight = blue_density / temp1; + haze_weight = haze_density.x / temp1; + + // Compute sunlight from P & lightnorm (for long rays like sky) + temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y ); + temp2.y = 1. / temp2.y; + sunlight *= exp( - light_atten * temp2.y); + + // Distance + temp2.z = Plen * density_multiplier.x; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z); + + + // Compute haze glow + temp2.x = dot(Pn, lightnorm.xyz); + temp2.x = 1. - temp2.x; + // temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .001); + // Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + // Higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + // Add "minimum anti-solar illumination" + temp2.x += .25; + + + // Haze color above cloud + vary_HazeColor = ( blue_horizon * blue_weight * (sunlight + ambient) + + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + ambient) + ); + + + // Increase ambient when there are more clouds + vec4 tmpAmbient = ambient; + tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5; + + // Dim sunlight by cloud shadow percentage + sunlight *= (1. - cloud_shadow.x); + + // Haze color below cloud + vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient) + + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient) + ); + + // Final atmosphere additive + vary_HazeColor *= (1. - temp1); + + // Attenuate cloud color by atmosphere + temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds + + // At horizon, blend high altitude sky color towards the darker color below the clouds + vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1)); + + // won't compile on mac without this being set + //vary_AtmosAttenuation = vec3(0.0,0.0,0.0); +} + diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl new file mode 100644 index 0000000000..b7678cac66 --- /dev/null +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -0,0 +1,35 @@ +/** + * @file transportF.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +////////////////////////////////////////////////////////// +// The fragment shader for the terrain atmospherics +////////////////////////////////////////////////////////// + +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); + +uniform sampler2D cloudMap; +uniform vec4 cloud_pos_density1; + +vec3 atmosTransport(vec3 light) { + light *= getAtmosAttenuation().r; + light += getAdditiveColor() * 2.0; + return light; +} + +vec3 fullbrightAtmosTransport(vec3 light) { + float brightness = dot(light.rgb, vec3(0.33333)); + + return mix(atmosTransport(light.rgb), light.rgb + getAdditiveColor().rgb, brightness * brightness); +} + +vec3 fullbrightShinyAtmosTransport(vec3 light) { + float brightness = dot(light.rgb, vec3(0.33333)); + + return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness); +} + diff --git a/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl index 2505afea65..04c10536e0 100644 --- a/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl +++ b/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl @@ -1,10 +1,14 @@ -vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseCol); -mat4 getSkinnedTransform(); -void default_scatter(vec3 viewVec, vec3 lightDir); +/** + * @file avatarV.glsl + * + * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc. + * $License$ + */ -attribute vec4 materialColor; //2 +vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol); +mat4 getSkinnedTransform(); +void calcAtmospherics(vec3 inPositionEye); -attribute vec4 binormal; //6 attribute vec4 clothing; //4 attribute vec4 gWindDir; //7 @@ -27,102 +31,80 @@ void main() norm.z = dot(trans[2].xyz, gl_Normal); norm = normalize(norm); - vec3 binorm; - binorm.x = dot(trans[0].xyz, binormal.xyz); - binorm.y = dot(trans[1].xyz, binormal.xyz); - binorm.z = dot(trans[2].xyz, binormal.xyz); - norm = normalize(norm); - //wind vec4 windEffect; - windEffect = vec4(dot(norm, gWindDir.xyz)); // DP3 windEffect, blendNorm, gWindDir; - pos.x = dot(trans[2].xyz, gl_Vertex.xyz); // DP3 blendPos.x, blendMatZ, iPos; + windEffect = vec4(dot(norm, gWindDir.xyz)); + pos.x = dot(trans[2].xyz, gl_Vertex.xyz); windEffect.xyz = pos.x * vec3(0.015, 0.015, 0.015) - + windEffect.xyz; // MAD windEffect.xyz, blendPos.x, {0.015, 0.015, 0.015, 0}, windEffect; - windEffect.w = windEffect.w * 2.0 + 1.0; // MAD windEffect.w, windEffect, {0, 0, 0, 2}, {0, 0, 0, 1}; # move wind offset value to [-1, 3] - windEffect.w = windEffect.w*gWindDir.w; // MUL windEffect.w, windEffect, gWindDir; # modulate wind strength + + windEffect.xyz; + windEffect.w = windEffect.w * 2.0 + 1.0; // move wind offset value to [-1, 3] + windEffect.w = windEffect.w*gWindDir.w; // modulate wind strength windEffect.xyz = windEffect.xyz*gSinWaveParams.xyz - +vec3(gSinWaveParams.w); // MAD windEffect.xyz, windEffect, gSinWaveParams, gSinWaveParams.w; # use sin wave params to scale and offset input + +vec3(gSinWaveParams.w); // use sin wave params to scale and offset input //reduce to period of 2 PI vec4 temp1, temp0, temp2, offsetPos; - temp1.xyz = windEffect.xyz * gPiConstants.x; // MUL temp1.xyz, windEffect, gPiConstants.x; # change input as multiple of [0-2PI] to [0-1] - temp0.y = mod(temp1.x,1.0); // EXP temp0, temp1.x; # find mod(x, 1) - windEffect.x = temp0.y * gPiConstants.y; // MUL windEffect.x, temp0.y, gPiConstants.y; # scale from [0,1] to [0, 2PI] - temp1.z = temp1.z - gPiConstants.w; // ADD temp1.z, temp1.z, -gPiConstants.w; # shift normal oscillation by PI/2 - temp0.y = mod(temp1.z,1.0); // EXP temp0, temp1.z; # find mod(x, 1) + temp1.xyz = windEffect.xyz * gPiConstants.x; // change input as multiple of [0-2PI] to [0-1] + temp0.y = mod(temp1.x,1.0); + windEffect.x = temp0.y * gPiConstants.y; // scale from [0,1] to [0, 2PI] + temp1.z = temp1.z - gPiConstants.w; // shift normal oscillation by PI/2 + temp0.y = mod(temp1.z,1.0); - windEffect.z = temp0.y * gPiConstants.y; // MUL windEffect.z, temp0.y, gPiConstants.y; # scale from [0,1] to [0, 2PI] - windEffect.xyz = windEffect.xyz + vec3(-3.141592); // # offset to [-PI, PI] - // ADD windEffect.xyz, windEffect, {-3.141592, -3.141592, -3.141592, -3.141592}; + windEffect.z = temp0.y * gPiConstants.y; // scale from [0,1] to [0, 2PI] + windEffect.xyz = windEffect.xyz + vec3(-3.141592); // offset to [-PI, PI] + //calculate sinusoid vec4 sinWave; - temp1 = windEffect*windEffect; // MUL temp1, windEffect, windEffect; # x^2 + temp1 = windEffect*windEffect; sinWave = -temp1 * gMinMaxConstants.w - + vec4(gMinMaxConstants.z); // MAD sinWave, -temp1, gMinMaxConstants.w, gMinMaxConstants.z; # y = -(x^2)/7! + 1/5! - sinWave = sinWave * -temp1 + vec4(gMinMaxConstants.y); // MAD sinWave, sinWave, -temp1, gMinMaxConstants.y; # y = -(x^2) * (-(x^2)/7! + 1/5!) + 1/3! - sinWave = sinWave * -temp1 + vec4(gMinMaxConstants.x); // MAD sinWave, sinWave, -temp1, gMinMaxConstants.x; # y = -(x^2) * (-(x^2) * (-(x^2)/7! + 1/5!) + 1/3!) + 1 - sinWave = sinWave * windEffect; // MUL sinWave, sinWave, windEffect; # y = x * (-(x^2) * (-(x^2) * (-(x^2)/7! + 1/5!) + 1/3!) + 1) + + vec4(gMinMaxConstants.z); // y = -(x^2)/7! + 1/5! + sinWave = sinWave * -temp1 + vec4(gMinMaxConstants.y); // y = -(x^2) * (-(x^2)/7! + 1/5!) + 1/3! + sinWave = sinWave * -temp1 + vec4(gMinMaxConstants.x); // y = -(x^2) * (-(x^2) * (-(x^2)/7! + 1/5!) + 1/3!) + 1 + sinWave = sinWave * windEffect; // y = x * (-(x^2) * (-(x^2) * (-(x^2)/7! + 1/5!) + 1/3!) + 1) // sinWave.x holds sin(norm . wind_direction) with primary frequency // sinWave.y holds sin(norm . wind_direction) with secondary frequency // sinWave.z hold cos(norm . wind_direction) with primary frequency sinWave.xyz = sinWave.xyz * gWindDir.w - + vec3(windEffect.w); // MAD sinWave.xyz, sinWave, gWindDir.w, windEffect.w; # multiply by wind strength in gWindDir.w [-wind, wind] + + vec3(windEffect.w); // multiply by wind strength in gWindDir.w [-wind, wind] // add normal facing bias offset [-wind,wind] -> [-wind - .25, wind + 1] - temp1 = vec4(dot(norm, gGravity.xyz)); // DP3 temp1, blendNorm, gGravity; # how much is this normal facing in direction of gGravity? - temp1 = min(temp1, vec4(0.2,0.0,0.0,0.0)); // MIN temp1, temp1, {0.2, 0, 0, 0}; # clamp [-1, 1] to [-1, 0.2] - temp1 = temp1*vec4(1.5,0.0,0.0,0.0); // MUL temp1, temp1, {1.5, 0, 0, 0}; # scale from [-1,0.2] to [-1.5, 0.3] - sinWave.x = sinWave.x + temp1.x; // ADD sinWave.x, sinWave, temp1; # add gGravity effect to sinwave (only primary frequency) - sinWave.xyz = sinWave.xyz * clothing.w; // MUL sinWave.xyz, sinWave, iClothing.w; # modulate by clothing coverage + temp1 = vec4(dot(norm, gGravity.xyz)); // how much is this normal facing in direction of gGravity? + temp1 = min(temp1, vec4(0.2,0.0,0.0,0.0)); // clamp [-1, 1] to [-1, 0.2] + temp1 = temp1*vec4(1.5,0.0,0.0,0.0); // scale from [-1,0.2] to [-1.5, 0.3] + sinWave.x = sinWave.x + temp1.x; // add gGravity effect to sinwave (only primary frequency) + sinWave.xyz = sinWave.xyz * clothing.w; // modulate by clothing coverage - sinWave.xyz = max(sinWave.xyz, vec3(-1.0, -1.0, -1.0)); // MAX sinWave.xyz, sinWave, {-1, -1, -1, -1}; # clamp to underlying body shape - offsetPos = clothing * sinWave.x; // MUL offsetPos, iClothing, sinWave.x; # multiply wind effect times clothing displacement - temp2 = gWindDir*sinWave.z + vec4(norm,0); // MAD temp2, gWindDir, sinWave.z, blendNorm; # calculate normal offset due to wind oscillation - offsetPos = vec4(1.0,1.0,1.0,0.0)*offsetPos+gl_Vertex; // MAD offsetPos, {1.0, 1.0, 1.0, 0.0}, offsetPos, iPos; # add to offset vertex position, and zero out effect from w - norm += temp2.xyz*2.0; // MAD blendNorm, temp2, {2, 2, 2, 2}, blendNorm; # add sin wave effect on normals (exaggerated) + sinWave.xyz = max(sinWave.xyz, vec3(-1.0, -1.0, -1.0)); // clamp to underlying body shape + offsetPos = clothing * sinWave.x; // multiply wind effect times clothing displacement + temp2 = gWindDir*sinWave.z + vec4(norm,0); // calculate normal offset due to wind oscillation + offsetPos = vec4(1.0,1.0,1.0,0.0)*offsetPos+gl_Vertex; // add to offset vertex position, and zero out effect from w + norm += temp2.xyz*2.0; // add sin wave effect on normals (exaggerated) //add "backlighting" effect float colorAcc; - colorAcc = 1.0 - clothing.w; // SUB colorAcc, {1, 1, 1, 1}, iClothing; - norm.z -= colorAcc * 0.2; // MAD blendNorm, colorAcc.w, {0, 0, -0.2, 0}, blendNorm; + colorAcc = 1.0 - clothing.w; + norm.z -= colorAcc * 0.2; //renormalize normal (again) - norm = normalize(norm); // DP3 divisor.w, blendNorm, blendNorm; - // RSQ divisor.xyz, divisor.w; - // MUL blendNorm.xyz, blendNorm, divisor; - - //project binormal to normal plane to ensure orthogonality - temp2 = vec4(dot(norm, binorm)); // DP3 temp2, blendNorm, blendBinorm; - binorm = binorm - temp2.xyz; // SUB blendBinorm, blendBinorm, temp2; - - //renormalize binormal - binorm = normalize(binorm); // DP3 divisor.w, blendBinorm, blendBinorm; - // RSQ divisor.xyz, divisor.w; - // MUL blendBinorm.xyz, blendBinorm, divisor; + norm = normalize(norm); pos.x = dot(trans[0], offsetPos); pos.y = dot(trans[1], offsetPos); pos.z = dot(trans[2], offsetPos); pos.w = 1.0; + + calcAtmospherics(pos.xyz); - vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color.rgb); + vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.0)); gl_FrontColor = color; gl_Position = gl_ProjectionMatrix * pos; - vec3 N = norm; - vec3 B = binorm; - vec3 T = cross(N,B); - //gl_TexCoord[1].xy = gl_MultiTexCoord0.xy + 1.0/512.0 * vec2(dot(T,gl_LightSource[0].position.xyz), - // dot(B,gl_LightSource[0].position.xyz)); - gl_TexCoord[2] = vec4(pos.xyz, 1.0); - default_scatter(pos.xyz, gl_LightSource[0].position.xyz); - -} \ No newline at end of file + +} diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsSpecularV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsSpecularV.glsl new file mode 100644 index 0000000000..bf5c78f3ea --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsSpecularV.glsl @@ -0,0 +1,44 @@ +/** + * @file sumLightsV.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 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol); + +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 = vec4(0.0, 0.0, 0.0, color.a); + + vec3 view = normalize(pos); + + /// collect all the specular values from each calcXXXLightSpecular() function + vec4 specularSum = vec4(0.0); + + // Collect normal lights (need to be divided by two, as we later multiply by 2) + 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 += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[2].position.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation,gl_LightSource[2].diffuse.rgb); + col.rgb += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[3].position.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].quadraticAttenuation,gl_LightSource[3].diffuse.rgb); + col.rgb += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[4].position.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].quadraticAttenuation,gl_LightSource[4].diffuse.rgb); + col.rgb += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[5].position.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].quadraticAttenuation,gl_LightSource[5].diffuse.rgb); + col.rgb += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[6].position.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation,gl_LightSource[6].diffuse.rgb); + col.rgb += calcPointLightSpecular(specularSum, view, pos, norm, gl_LightSource[7].position.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation,gl_LightSource[7].diffuse.rgb); + col.rgb = scaleDownLight(col.rgb); + + // Add windlight lights + 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/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl new file mode 100644 index 0000000000..1c5234c450 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl @@ -0,0 +1,41 @@ +/** + * @file sumLightsV.glsl + * + * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc. + * $License$ + */ + +float calcDirectionalLight(vec3 n, vec3 l); +float calcPointLight(vec3 v, vec3 n, vec4 lp, float la); + +vec3 atmosAmbient(vec3 light); +vec3 atmosAffectDirectionalLight(float lightIntensity); +vec3 scaleDownLight(vec3 light); +vec3 scaleUpLight(vec3 light); + +vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) +{ + vec4 col; + col.a = color.a; + + // Add windlight lights + col.rgb = atmosAffectDirectionalLight(calcDirectionalLight(norm, gl_LightSource[0].position.xyz)); + col.rgb += atmosAmbient(baseLight.rgb); + col.rgb = scaleUpLight(col.rgb); + + // Collect normal lights (need to be divided by two, as we later multiply by 2) + col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation); + col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation); + col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation); + col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation); + col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation); + col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation); + col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); + col.rgb = scaleDownLight(col.rgb); + + + col.rgb = min(col.rgb*color.rgb, 1.0); + + return col; +} + diff --git a/indra/newview/app_settings/shaders/shader_heirarchy.txt b/indra/newview/app_settings/shaders/shader_heirarchy.txt new file mode 100644 index 0000000000..d8bbf69b38 --- /dev/null +++ b/indra/newview/app_settings/shaders/shader_heirarchy.txt @@ -0,0 +1,176 @@ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +avatar/avatarV.glsl - gAvatarProgram, gAvatarWaterProgram + main() - avatar/avatarV.glsl + getSkinnedTransform() - avatarSkinV.glsl + calcAtmospherics() - windlight/atmosphericsV.glsl + calcLighting() - lighting/lightV.glsl + sumLights() - lighting/sumLightsV.glsl + calcDirectionalLight() - lighting/lightFuncV.glsl + calcPointLight() - lighting/lightFuncV.glsl + scaleDownLight() - windlight/atmosphericsHelpersV.glsl + atmosAmbient() - windlight/atmosphericsHelpersV.glsl + atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +avatar/avatarF.glsl - gAvatarProgram + main() - avatar/avatarF.glsl + default_lighting() - lighting/lightF.glsl + calc_default_lighting() - lighting/lightF.glsl + atmosLighting() - windlight/atmosphericsF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +avatar/eyeballV.glsl - gAvatarEyeballProgram + main() - avatar/eyeballV.glsl + calcAtmospherics() - windlight/atmosphericsV.glsl + calcLightingSpecular() - lighting/lightSpecularV.glsl + sumLightsSpecular() - lighting/sumLightsSpecularV.glsl + calcDirectionalLightSpecular() - lighting/lightFuncSpecularV.glsl + calcPointLightSpecular() - lighting/lightFuncSpecularV.glsl + atmosAmbient() - windlight/atmosphericsHelpersV.glsl + atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl + atmosGetDiffuseSunlightColor() - windlight/atmosphericsHelpersV.glsl + scaleDownLight() - windlight/atmosphericsHelpersV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +avatar/eyeballF.glsl - gAvatarEyeballProgram + main() - avatar/eyeballF.glsl + default_lighting() - lighting/lightF.glsl + calc_default_lighting() - lighting/lightF.glsl + atmosLighting() - windlight/atmosphericsF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +avatar/pickAvatarV.glsl - gAvatarPickProgram + main() - avatar/pickAvatarV.glsl + getSkinnedTransform() - avatarSkinV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +avatar/pickAvatarF.glsl - gAvatarPickProgram + main() - avatar/pickAvatarF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +environment/terrainV.glsl - gTerrainProgram, gTerrainWaterProgram + texgen_object() - environment/terrainV.glsl + main() - environment/terrainV.glsl + texgen_object() - environment/terrainV.glsl + calcAtmospherics() - windlight/atmosphericsV.glsl + calcLighting() - lighting/lightV.glsl + sumLights() - lighting/sumLightsV.glsl + calcDirectionalLight() - lighting/lightFuncV.glsl + calcPointLight() - lighting/lightFuncV.glsl + scaleDownLight() - windlight/atmosphericsHelpersV.glsl + atmosAmbient() - windlight/atmosphericsHelpersV.glsl + atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +environment/terrainF.glsl - gTerrainProgram + main() - environment/terrainF.glsl + atmosLighting() - windlight/atmosphericsF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +environment/terrainWaterF.glsl - gTerrainWaterProgram + main() - environment/terrainWaterF.glsl + atmosLighting() - windlight/atmosphericsF.glsl + applyWaterFog() - environment/waterFogF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +environment/underWaterF.glsl - gUnderWaterProgram + applyWaterFog() - environment/underWaterF.glsl (NOTE: different than one in waterFogF.glsl) + main() - environment/underWaterF.glsl + applyWaterFog() - environment/underWaterF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +environment/waterV.glsl - gWaterProgram, gUnderWaterProgram + main() - environment/waterV.glsl + calcAtmospherics() - windlight/atmosphericsV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +environment/waterF.glsl - gWaterProgram + main() - environment/waterF.glsl + atmosTransport() - windlight/transportF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/fullbrightV.glsl - gObjectFullbrightProgram, gObjectFullbrightWaterProgram + main() - objects/fullbrightV.glsl + calcAtmospherics() - windlight/atmosphericsV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/fullbrightF.glsl - gObjectFullbrightProgram + main() - objects/fullbrightF.glsl + fullbright_lighting() - lighting/lightFullbrightF.glsl + fullbrightAtmosTransport() - windlight/transportF.glsl + atmosTransport() - windlight/transportF.glsl + fullbrightScaleSoftClip() - windlight/gammaF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/fullbrightShinyV.glsl - gObjectFullbrightShinyProgram + main() - objects/fullbrightShinyV.glsl + calcAtmospherics() - windlight/atmosphericsV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/fullbrightShinyF.glsl - gObjectFullbrightShinyProgram + main() - objects/fullbrightShinyF.glsl + fullbright_shiny_lighting() - lighting/lightFullbrightShinyF.glsl + fullbrightShinyAtmosTransport() - windlight/transportF.glsl + atmosTransport() - windlight/transportF.glsl + fullbrightScaleSoftClip() - windlight/gammaF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/fullbrightWaterF.glsl - gObjectFullbrightWaterProgram + main() - objects/fullbrightWaterF.glsl + fullbright_lighting_water() - lighting/lightFullbrightWaterF.glsl + fullbrightAtmosTransport() - windlight/transportF.glsl + atmosTransport() - windlight/transportF.glsl + applyWaterFog() - environment/waterFogF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/shinyV.glsl - gObjectShinyProgram, gObjectShinyWaterProgram + main() - objects/shinyV.glsl + calcAtmospherics() - windlight/atmosphericsV.glsl + calcLighting() - lighting/lightV.glsl + calcLighting(vec4) - lighting/lightV.glsl + sumLights() - lighting/sumLightsV.glsl + calcDirectionalLight() - lighting/lightFuncV.glsl + calcPointLight() - lighting/lightFuncV.glsl + scaleDownLight() - windlight/atmosphericsHelpersV.glsl + atmosAmbient() - windlight/atmosphericsHelpersV.glsl + atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/shinyF.glsl - gObjectShinyProgram + main() - objects/shinyF.glsl + shiny_lighting() - lighting/lightShinyF.glsl + atmosLighting() - windlight/atmosphericsF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/shinyWaterF.glsl - gObjectShinyWaterProgram + main() - objects/shinyWaterF.glsl + shiny_lighting_water() - lighting/lightShinyWaterF.glsl + atmosLighting() - windlight/atmosphericsF.glsl + applyWaterFog() - environment/waterFogF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/simpleV.glsl - gObjectSimpleProgram, gObjectSimpleWaterProgram + main() - objects/simpleV.glsl + calcAtmospherics() - windlight/atmosphericsV.glsl + calcLighting() - lighting/lightV.glsl + sumLights() - lighting/sumLightsV.glsl + calcDirectionalLight() - lighting/lightFuncV.glsl + calcPointLight() - lighting/lightFuncV.glsl + scaleDownLight() - windlight/atmosphericsHelpersV.glsl + atmosAmbient() - windlight/atmosphericsHelpersV.glsl + atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/simpleF.glsl - gObjectSimpleProgram + main() - objects/simpleF.glsl + default_lighting() - lighting/lightF.glsl + atmosLighting() - windlight/atmosphericsF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +objects/simpleWaterF.glsl - gObjectSimpleWaterProgram, gAvatarWaterProgram + main() - objects/simpleWaterF.glsl + default_lighting_water() - lighting/lightWaterF.glsl + atmosLighting() - windlight/atmosphericsF.glsl + applyWaterFog() - environment/waterFogF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +windlight/skyV.glsl - gWLSkyProgram + main() - windlight/skyV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +windlight/skyF.glsl - gWLSkyProgram + main() - windlight/skyF.glsl + scaleSoftClip() - windlight/gammaF.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +windlight/cloudsV.glsl - gWLCloudProgram + main() - windlight/cloudsV.glsl +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +windlight/cloudsF.glsl - gWLCloudProgram + main() - windlight/cloudsF.glsl + scaleSoftClip() - windlight/gammaF.glsl + + -- cgit v1.2.3