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 | |
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')
3 files changed, 19 insertions, 4 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); diff --git a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl index ddb1b79681..223e55eb69 100644 --- a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl @@ -30,7 +30,6 @@ uniform sampler2D bumpMap; #ifdef TRANSPARENT_WATER uniform sampler2D screenTex; -uniform sampler2D screenDepth; #endif uniform vec4 fogCol; diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index f53bc2e13e..b364e454e8 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -76,7 +76,7 @@ uniform sampler2D bumpMap2; uniform float blend_factor; #ifdef TRANSPARENT_WATER uniform sampler2D screenTex; -uniform sampler2D screenDepth; +uniform sampler2D depthMap; #endif uniform sampler2D refTex; @@ -210,7 +210,7 @@ void main() #ifdef TRANSPARENT_WATER vec4 fb = texture(screenTex, distort2); - float depth = texture(screenDepth, distort2).r; + float depth = texture(depthMap, distort2).r; vec3 refPos = getPositionWithNDC(vec3(distort2*2.0-vec2(1.0), depth*2.0-1.0)); if (refPos.z > pos.z-0.05) @@ -218,7 +218,7 @@ void main() //we sampled an above water sample, don't distort distort2 = distort; fb = texture(screenTex, distort2); - depth = texture(screenDepth, distort2).r; + depth = texture(depthMap, distort2).r; refPos = getPositionWithNDC(vec3(distort2 * 2.0 - vec2(1.0), depth * 2.0 - 1.0)); } |