diff options
author | Dave Parks <davep@lindenlab.com> | 2023-12-11 15:28:25 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2023-12-11 15:28:25 -0600 |
commit | f3b87145775d3803306036d1e31fa39177f2600e (patch) | |
tree | 3002aba971e65a144da09344dd325f634c24cd1b /indra/newview/app_settings/shaders/class3/deferred | |
parent | 4024a4df3b36b55ce2f05e02218251e15a4a2286 (diff) |
SL-20611 Followup -- fix for artifacts on water surface from GPUs that don't like to read from a depth buffer that is bound for writing
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred')
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl index 025bcdaf3e..13619a82d3 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl @@ -35,10 +35,26 @@ float getDepth(vec2 pos_screen); vec4 getWaterFogView(vec3 pos); +uniform int above_water; + void main() { vec2 tc = vary_fragcoord.xy/vary_fragcoord.w*0.5+0.5; float depth = getDepth(tc.xy); + + if (above_water > 0) + { + // we want to depth test when the camera is above water, but some GPUs have a hard time + // with depth testing against render targets that are bound for sampling in the same shader + // so we do it manually here + + float cur_depth = vary_fragcoord.z/vary_fragcoord.w*0.5+0.5; + if (cur_depth > depth) + { + discard; + } + } + vec4 pos = getPositionWithDepth(tc, depth); vec4 norm = texture(normalMap, tc); |