summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
diff options
context:
space:
mode:
authorRunitaiLinden <davep@lindenlab.com>2023-11-30 12:01:45 -0600
committerRunitaiLinden <davep@lindenlab.com>2023-11-30 12:01:45 -0600
commit68875523e09f9fe06fc4b3cd5225995bb13966c3 (patch)
tree75b5aaae7665360c152c399a8cf80cb6147902e2 /indra/newview/app_settings/shaders/class3
parent964f9e74d5e97fc46fc74d6afff97dad5c6381c3 (diff)
SL-20611 Incorporate water haze into new post effect atmospherics goodness
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/waterHazeV.glsl59
-rw-r--r--indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class3/environment/waterF.glsl3
5 files changed, 71 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
index 7b77a2f5fb..e8f7d73f1f 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
@@ -68,23 +68,21 @@ void main()
calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
vec3 sunlit_linear = srgb_to_linear(sunlit);
- vec3 amblit_linear = amblit;
-
+
+ // mask off atmospherics below water (when camera is under water)
bool do_atmospherics = false;
-
- // mask off atmospherics below water
- if (dot(pos.xyz, waterPlane.xyz) + waterPlane.w > 0.0)
+
+ if (dot(vec3(0), waterPlane.xyz) + waterPlane.w > 0.0 ||
+ dot(pos.xyz, waterPlane.xyz) + waterPlane.w > 0.0)
{
do_atmospherics = true;
}
+
vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
- {
- }
- else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
+ if (depth >= 1.0)
{
//should only be true of WL sky, just port over base color value
discard;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl
index f63d70cbd7..025bcdaf3e 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl
@@ -26,7 +26,7 @@
out vec4 frag_color;
// Inputs
-in vec2 vary_fragcoord;
+in vec4 vary_fragcoord;
uniform sampler2D normalMap;
@@ -37,20 +37,11 @@ vec4 getWaterFogView(vec3 pos);
void main()
{
- vec2 tc = vary_fragcoord.xy;
+ vec2 tc = vary_fragcoord.xy/vary_fragcoord.w*0.5+0.5;
float depth = getDepth(tc.xy);
vec4 pos = getPositionWithDepth(tc, depth);
vec4 norm = texture(normalMap, tc);
- if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
- {
- }
- else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
- {
- //should only be true of WL sky, just port over base color value
- discard;
- }
-
vec4 fogged = getWaterFogView(pos.xyz);
frag_color.rgb = max(fogged.rgb, vec3(0)); //output linear since local lights will be added to this shader's results
diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterHazeV.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterHazeV.glsl
new file mode 100644
index 0000000000..16381a5d51
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class3/deferred/waterHazeV.glsl
@@ -0,0 +1,59 @@
+/**
+ * @file class3/deferred/waterHazeV.glsl
+ *
+ * $LicenseInfo:firstyear=2023&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2023, 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 position;
+
+uniform vec2 screen_res;
+
+out vec4 vary_fragcoord;
+
+// forwards
+void setAtmosAttenuation(vec3 c);
+void setAdditiveColor(vec3 c);
+
+uniform vec4 waterPlane;
+
+uniform int above_water;
+
+uniform mat4 modelview_projection_matrix;
+
+void main()
+{
+ //transform vertex
+ vec4 pos = vec4(position.xyz, 1.0);
+
+ if (above_water > 0)
+ {
+ pos = modelview_projection_matrix*pos;
+ }
+
+ gl_Position = pos;
+
+ // appease OSX GLSL compiler/linker by touching all the varyings we said we would
+ setAtmosAttenuation(vec3(1));
+ setAdditiveColor(vec3(0));
+
+ vary_fragcoord = pos;
+}
diff --git a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl
index 924f356f35..ddb1b79681 100644
--- a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl
@@ -77,5 +77,7 @@ void main()
vec4 fb = vec4(waterFogColorLinear, 0.0);
#endif
- frag_color = max(applyWaterFogViewLinearNoClip(vary_position, fb), vec4(0));
+ fb = applyWaterFogViewLinearNoClip(vary_position, fb);
+
+ frag_color = max(fb, vec4(0));
}
diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
index 8bc5f3cc50..f53bc2e13e 100644
--- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
@@ -32,7 +32,6 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
#endif
vec3 scaleSoftClipFragLinear(vec3 l);
-vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive);
vec4 applyWaterFogViewLinear(vec3 pos, vec4 color);
@@ -281,8 +280,6 @@ void main()
color = ((1.0 - f) * color) + fb.rgb;
- color = atmosFragLightingLinear(color, additive, atten);
-
float spec = min(max(max(punctual.r, punctual.g), punctual.b), 0.05);
frag_color = max(vec4(color, spec), vec4(0));