From 68875523e09f9fe06fc4b3cd5225995bb13966c3 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 30 Nov 2023 12:01:45 -0600 Subject: SL-20611 Incorporate water haze into new post effect atmospherics goodness --- .../shaders/class1/deferred/fullbrightF.glsl | 6 +-- .../shaders/class3/deferred/hazeF.glsl | 16 +++--- .../shaders/class3/deferred/waterHazeF.glsl | 13 +---- .../shaders/class3/deferred/waterHazeV.glsl | 59 ++++++++++++++++++++++ .../shaders/class3/environment/underWaterF.glsl | 4 +- .../shaders/class3/environment/waterF.glsl | 3 -- 6 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class3/deferred/waterHazeV.glsl (limited to 'indra/newview/app_settings/shaders') diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 2798c59f1c..1de8b25a7d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -82,12 +82,12 @@ void main() vec3 additive; vec3 atten; calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten); -#endif - -#ifndef IS_HUD color.rgb = srgb_to_linear(color.rgb); + +#ifdef IS_ALPHA color.rgb = atmosFragLighting(color.rgb, additive, atten); +#endif vec4 fogged = applyWaterFogViewLinear(pos, vec4(color.rgb, final_alpha)); color.rgb = fogged.rgb; 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)); -- cgit v1.2.3