diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-03 07:54:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-03 07:54:59 +0200 |
commit | 15fdf7bc8683920f2f4650364ed4448564610b88 (patch) | |
tree | 308aa25c41b3dcebaeda9fb19786b3fd752af69c /servers | |
parent | ed185de790da9f23e6b039d45ea3e5cfb922676f (diff) | |
parent | d38671827bd5fe917a2382baf95b3c01c5fffd17 (diff) |
Merge pull request #58611 from Calinou/ssr-fix-blend-margin
Fade screen-space reflection towards inner margin
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl index d85ab3af2e..246ef81cb2 100644 --- a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl @@ -182,17 +182,18 @@ void main() { if (found) { float margin_blend = 1.0; - vec2 margin = vec2((params.screen_size.x + params.screen_size.y) * 0.5 * 0.05); // make a uniform margin - if (any(bvec4(lessThan(pos, -margin), greaterThan(pos, params.screen_size + margin)))) { - // clip outside screen + margin + vec2 margin = vec2((params.screen_size.x + params.screen_size.y) * 0.05); // make a uniform margin + if (any(bvec4(lessThan(pos, vec2(0.0, 0.0)), greaterThan(pos, params.screen_size)))) { + // clip at the screen edges imageStore(ssr_image, ssC, vec4(0.0)); return; } { - //blend fading out towards external margin - vec2 margin_grad = mix(pos - params.screen_size, -pos, lessThan(pos, vec2(0.0))); - margin_blend = 1.0 - smoothstep(0.0, margin.x, max(margin_grad.x, margin_grad.y)); + //blend fading out towards inner margin + // 0.5 = midpoint of reflection + vec2 margin_grad = mix(params.screen_size - pos, pos, lessThan(pos, params.screen_size * 0.5)); + margin_blend = smoothstep(0.0, margin.x * margin.y, margin_grad.x * margin_grad.y); //margin_blend = 1.0; } |