Skip to content

Commit

Permalink
Add maximum roughness cutoff to SSR to improve performance
Browse files Browse the repository at this point in the history
In a test scene with mixed rough and non-rough materials, this saves
upwards of 0.15 ms of GPU time with very little visual artifacting
(GTX 1080, 2560×1440).
  • Loading branch information
Calinou committed Dec 10, 2022
1 parent e9c7140 commit 7745bd4
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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));

////////////////

Expand Down Expand Up @@ -220,7 +231,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;
Expand Down

0 comments on commit 7745bd4

Please sign in to comment.