summaryrefslogtreecommitdiff
path: root/servers/rendering/renderer_rd/shaders/effects
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-12-15 09:20:29 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-12-15 09:20:29 +0100
commite1bcadd12daa603a265171485cc770d4bfa3ef4a (patch)
tree7d1335260468b0c11532b1879d0865e4af3f2a49 /servers/rendering/renderer_rd/shaders/effects
parent4e5714c23a35b35f50fe84b67f785a9ab81fbb35 (diff)
parent7745bd42a68787eea848af2258431213ed9a1555 (diff)
Merge pull request #56804 from Calinou/ssr-add-max-roughness-cutoff
Add maximum roughness cutoff to SSR to improve performance
Diffstat (limited to 'servers/rendering/renderer_rd/shaders/effects')
-rw-r--r--servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl16
1 files changed, 13 insertions, 3 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 a8b2d77718..631d1968b0 100644
--- a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl
+++ b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl
@@ -66,6 +66,19 @@ void main() {
vec4 normal_roughness = imageLoad(source_normal_roughness, ssC);
vec3 normal = normal_roughness.xyz * 2.0 - 1.0;
+ float roughness = normal_roughness.w;
+
+ // The roughness cutoff of 0.6 is chosen to match the roughness fadeout from GH-69828.
+ if (roughness > 0.6) {
+ // Do not compute SSR for rough materials to improve performance at the cost of
+ // subtle artifacting.
+#ifdef MODE_ROUGH
+ imageStore(blur_radius_image, ssC, vec4(0.0));
+#endif
+ imageStore(ssr_image, ssC, vec4(0.0));
+ return;
+ }
+
normal = normalize(normal);
normal.y = -normal.y; //because this code reads flipped
@@ -81,8 +94,6 @@ void main() {
imageStore(ssr_image, ssC, vec4(0.0));
return;
}
- //ray_dir = normalize(view_dir - normal * dot(normal,view_dir) * 2.0);
- //ray_dir = normalize(vec3(1.0, 1.0, -1.0));
////////////////
@@ -223,7 +234,6 @@ void main() {
// if roughness is enabled, do screen space cone tracing
float blur_radius = 0.0;
- float roughness = normal_roughness.w;
if (roughness > 0.001) {
float cone_angle = min(roughness, 0.999) * M_PI * 0.5;