diff options
author | Dave Parks <davep@lindenlab.com> | 2023-02-07 11:40:56 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2023-02-07 11:40:56 -0600 |
commit | b52699091da791a1349daf66d405f27ca2568ea9 (patch) | |
tree | c8c140c4691f3f4d53274bbaf7d8a734dec2d330 /indra/newview/app_settings/shaders/class1 | |
parent | c8fb3ad4de0575a0538b9532e819319f655613d1 (diff) |
SL-19147 Water quality pass. Remove gl_FragDepth writes from sky rendering (optimization). Incidental decruft.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
11 files changed, 58 insertions, 23 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index b45dfcd550..cf9ce646d1 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -125,7 +125,5 @@ void main() frag_data[0] = vec4(color.rgb, alpha1); frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,GBUFFER_FLAG_SKIP_ATMOS); - - gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 Stars and Clouds need same depth } diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index c87e754eca..e71d080fc5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -531,7 +531,7 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0); - color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness); + color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, 0.2); color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir)) * sunlit * 2.75 * scol; color += colorEmissive*0.5; @@ -551,14 +551,14 @@ void waterClip(vec3 pos) // TODO: make this less branchy if (waterSign > 0) { - if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) < -0.1) + if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) < 0.0) { discard; } } else { - if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) > -0.1) + if ((dot(pos.xyz, waterPlane.xyz) + waterPlane.w) > 0.0) { discard; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 7032c45603..41dd485fae 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -72,7 +72,5 @@ void main() frag_data[0] = vec4(c.rgb, c.a); frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0, 0.0, 0.0, GBUFFER_FLAG_HAS_ATMOS); - - gl_FragDepth = LL_SHADER_CONST_CLOUD_MOON_DEPTH; // SL-14113 } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl index c4922afd7d..7b9aa0a4dc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonV.glsl @@ -36,9 +36,11 @@ void main() { //transform vertex vec4 vert = vec4(position.xyz, 1.0); - vec4 pos = (modelview_matrix * vert); + vec4 pos = (modelview_projection_matrix * vert); - gl_Position = modelview_projection_matrix*vert; + // smash to *almost* far clip plane -- stars are still behind + pos.z = pos.w*0.999999; + gl_Position = pos; vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl index 0c398b263f..930338cefb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl @@ -97,7 +97,5 @@ void main() frag_data[0] = vec4(color.rgb, 1.0); frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0.0,0.0,0.0,GBUFFER_FLAG_SKIP_ATMOS); //1.0 in norm.w masks off fog - - gl_FragDepth = 0.99999f; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index 152316c117..cdafdba15c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -65,7 +65,5 @@ void main() frag_data[0] = col; frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS); - - gl_FragDepth = LL_SHADER_CONST_STAR_DEPTH; // SL-14113 Moon Haze -- Stars need to depth test behind the moon } diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl index bb2a2ee72b..37d1630252 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl @@ -40,8 +40,10 @@ void main() //transform vertex vec4 pos = modelview_projection_matrix * vec4(position, 1.0); -// bias z to fix SL-9806 and get stars to depth test against clouds - pos.z += 0.001f; + + // smash to far clip plane to + // avoid rendering on top of moon (do NOT write to gl_FragDepth, it's slow) + pos.z = pos.w; gl_Position = pos; diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl index 4ab8747629..e35ea83f0a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl @@ -58,7 +58,5 @@ void main() frag_data[0] = c; frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS); - - gl_FragDepth = 0.999988f; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl index 0d117c6bc7..d3dfa882f0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl @@ -44,6 +44,8 @@ void main() sun_fade = smoothstep(0.3, 1.0, (position.z + 50) / 512.0f); + // smash to *almost* far clip plane -- behind clouds but in front of stars + pos.z = pos.w*0.999999; gl_Position = pos; calcAtmospherics(pos.xyz); diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl new file mode 100644 index 0000000000..075397d96c --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -0,0 +1,34 @@ +/** + * @file waterF.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$ + */ + + // error fallback on compilation failure + +out vec4 frag_color; + +void main() +{ + frag_color = vec4(1,0,1,1); +} + diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl index e1cdeddcea..5765e04014 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl @@ -72,13 +72,8 @@ vec4 applyWaterFogView(vec3 pos, vec4 color) return color; } -vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit) +vec4 applyWaterFogViewLinearNoClip(vec3 pos, vec4 color, vec3 sunlit) { - if (dot(pos, waterPlane.xyz) + waterPlane.w > 0.0) - { - return color; - } - vec3 view = normalize(pos); //normalize view vector float es = -(dot(view, waterPlane.xyz)); @@ -118,6 +113,16 @@ vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit) return color; } +vec4 applyWaterFogViewLinear(vec3 pos, vec4 color, vec3 sunlit) +{ + 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)); |