summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorRunitaiLinden <davep@lindenlab.com>2023-11-16 16:46:12 -0600
committerRunitaiLinden <davep@lindenlab.com>2023-11-16 16:46:12 -0600
commitbdb53fd56d56c659941e7e63f83cefc366acef6d (patch)
tree89a6744852e7df622df02477a54c977aa91783d7 /indra/newview/app_settings/shaders/class1
parent361efcb9267f2c91f88198081bbe6ac2264766fd (diff)
SL-20611 Make haze effect local lights -- move sky and water haze to their own passes and unify sky and water haze in forward rendering shaders.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl48
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl1
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl1
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl11
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl50
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl81
8 files changed, 33 insertions, 177 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index 5d58cc91cd..2798c59f1c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -35,9 +35,7 @@ in vec3 vary_position;
in vec4 vertex_color;
in vec2 vary_texcoord0;
-#ifdef WATER_FOG
-vec4 applyWaterFogView(vec3 pos, vec4 color);
-#endif
+vec4 applyWaterFogViewLinear(vec3 pos, vec4 color);
vec3 srgb_to_linear(vec3 cs);
vec3 linear_to_srgb(vec3 cl);
@@ -86,18 +84,14 @@ void main()
calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten);
#endif
-#ifdef WATER_FOG
-
- vec4 fogged = applyWaterFogView(pos, vec4(color.rgb, final_alpha));
- color.rgb = fogged.rgb;
- color.a = fogged.a;
-#else
- color.a = final_alpha;
-#endif
#ifndef IS_HUD
color.rgb = srgb_to_linear(color.rgb);
color.rgb = atmosFragLighting(color.rgb, additive, atten);
+
+ vec4 fogged = applyWaterFogViewLinear(pos, vec4(color.rgb, final_alpha));
+ color.rgb = fogged.rgb;
+ color.a = fogged.a;
#endif
frag_color = max(color, vec4(0));
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
index cfdb393b34..140e01cc2a 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
@@ -30,12 +30,12 @@ uniform vec4 waterFogColor;
uniform float waterFogDensity;
uniform float waterFogKS;
-vec3 getPositionEye();
-
vec3 srgb_to_linear(vec3 col);
vec3 linear_to_srgb(vec3 col);
-vec4 applyWaterFogView(vec3 pos, vec4 color)
+// get a water fog color that will apply the appropriate haze to a color given
+// a blend function of (ONE, SOURCE_ALPHA)
+vec4 getWaterFogViewNoClip(vec3 pos)
{
vec3 view = normalize(pos);
//normalize view vector
@@ -67,38 +67,44 @@ vec4 applyWaterFogView(vec3 pos, vec4 color)
float L = min(t1/t2*t3, 1.0);
float D = pow(0.98, l*kd);
+
+ return vec4(srgb_to_linear(kc.rgb*L), D);
+}
+
+vec4 getWaterFogView(vec3 pos)
+{
+ if (dot(pos, waterPlane.xyz) + waterPlane.w > 0.0)
+ {
+ return vec4(0,0,0,1);
+ }
+
+ return getWaterFogViewNoClip(pos);
+}
+
+vec4 applyWaterFogView(vec3 pos, vec4 color)
+{
+ vec4 fogged = getWaterFogView(pos);
- color.rgb = color.rgb * D + kc.rgb * L;
+ color.rgb = color.rgb * fogged.a + fogged.rgb;
return color;
}
-vec4 applyWaterFogViewLinearNoClip(vec3 pos, vec4 color, vec3 sunlit)
+vec4 applyWaterFogViewLinearNoClip(vec3 pos, vec4 color)
{
- color.rgb = linear_to_srgb(color.rgb);
- color = applyWaterFogView(pos, color);
- color.rgb = srgb_to_linear(color.rgb);
+ vec4 fogged = getWaterFogViewNoClip(pos);
+ color.rgb *= fogged.a;
+ color.rgb += fogged.rgb;
return color;
}
-vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit)
+vec4 applyWaterFogViewLinear(vec3 pos, vec4 color)
{
if (dot(pos, waterPlane.xyz) + waterPlane.w > 0.0)
{
return color;
}
- return applyWaterFogViewLinearNoClip(pos, color, sunlit);
-}
-
-vec4 applyWaterFogViewLinear(vec3 pos, vec4 color)
-{
- return applyWaterFogViewLinear(pos, color, vec3(1));
-}
-
-vec4 applyWaterFog(vec4 color)
-{
- //normalize view vector
- return applyWaterFogViewLinear(getPositionEye(), color);
+ return applyWaterFogViewLinearNoClip(pos, color);
}
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl
index 6ecbfaecb1..4f88aed765 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsHelpersV.glsl
@@ -30,7 +30,6 @@ vec3 getSunlitColor();
vec3 getAmblitColor();
vec3 getAdditiveColor();
vec3 getAtmosAttenuation();
-vec3 getPositionEye();
uniform float scene_light_strength;
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl
index cc3617ba61..7b59e07243 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsV.glsl
@@ -42,7 +42,6 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
void calcAtmospherics(vec3 inPositionEye) {
vec3 P = inPositionEye;
- setPositionEye(P);
vec3 tmpsunlit = vec3(1);
vec3 tmpamblit = vec3(1);
vec3 tmpaddlit = vec3(1);
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl
index 34669a6796..9d5f60b313 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsF.glsl
@@ -44,5 +44,5 @@ vec3 getAdditiveColor()
vec3 getAtmosAttenuation()
{
- return vec3(vary_AtmosAttenuation);
+ return vary_AtmosAttenuation;
}
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl
index 1b854d80b3..0617bc9908 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsV.glsl
@@ -31,7 +31,6 @@ vec3 additive_color;
vec3 atmos_attenuation;
vec3 sunlit_color;
vec3 amblit_color;
-vec3 position_eye;
vec3 getSunlitColor()
{
@@ -51,16 +50,6 @@ vec3 getAtmosAttenuation()
return atmos_attenuation;
}
-vec3 getPositionEye()
-{
- return position_eye;
-}
-
-void setPositionEye(vec3 v)
-{
- position_eye = v;
-}
-
void setSunlitColor(vec3 v)
{
sunlit_color = v;
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl
deleted file mode 100644
index 7a6741fe0e..0000000000
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterF.glsl
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * @file class2\wl\atmosphericVarsWaterF.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-in vec3 vary_PositionEye;
-in vec3 vary_AdditiveColor;
-in vec3 vary_AtmosAttenuation;
-
-vec3 getSunlitColor()
-{
- return vec3(0,0,0);
-}
-vec3 getAmblitColor()
-{
- return vec3(0,0,0);
-}
-vec3 getAdditiveColor()
-{
- return vary_AdditiveColor;
-}
-vec3 getAtmosAttenuation()
-{
- return vary_AtmosAttenuation;
-}
-vec3 getPositionEye()
-{
- return vary_PositionEye;
-}
-
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl
deleted file mode 100644
index 23c3aed4d8..0000000000
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsVarsWaterV.glsl
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * @file class2\wl\atmosphericVarsWaterV.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-out vec3 vary_PositionEye;
-out vec3 vary_AdditiveColor;
-out vec3 vary_AtmosAttenuation;
-
-vec3 atmos_attenuation;
-vec3 sunlit_color;
-vec3 amblit_color;
-
-vec3 getSunlitColor()
-{
- return sunlit_color;
-}
-vec3 getAmblitColor()
-{
- return amblit_color;
-}
-
-vec3 getAdditiveColor()
-{
- return vary_AdditiveColor;
-}
-vec3 getAtmosAttenuation()
-{
- return atmos_attenuation;
-}
-
-vec3 getPositionEye()
-{
- return vary_PositionEye;
-}
-
-void setPositionEye(vec3 v)
-{
- vary_PositionEye = v;
-}
-
-void setSunlitColor(vec3 v)
-{
- sunlit_color = v;
-}
-
-void setAmblitColor(vec3 v)
-{
- amblit_color = v;
-}
-
-void setAdditiveColor(vec3 v)
-{
- vary_AdditiveColor = v;
-}
-
-void setAtmosAttenuation(vec3 v)
-{
- atmos_attenuation = v;
- vary_AtmosAttenuation = v;
-}