-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Various Solari improvements #21649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various Solari improvements #21649
Changes from all commits
c1a1710
dac71e9
4e8ab80
49c9f8f
191b794
55d0d59
a504705
3669f59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ fn specular_gi(@builtin(global_invocation_id) global_id: vec3<u32>) { | |
|
|
||
| var radiance: vec3<f32>; | ||
| var wi: vec3<f32>; | ||
| if surface.material.roughness > 0.04 { | ||
| if surface.material.roughness > 0.1 { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be worth There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe? Would have to test. I feel like for latency reasons, you'd want to trace the minimum amount of rays possible, even if some threads end up idle. |
||
| // Surface is very rough, reuse the ReSTIR GI reservoir | ||
| let gi_reservoir = gi_reservoirs_a[pixel_index]; | ||
| wi = normalize(gi_reservoir.sample_point_world_position - surface.world_position); | ||
|
|
@@ -59,25 +59,31 @@ fn specular_gi(@builtin(global_invocation_id) global_id: vec3<u32>) { | |
| var pixel_color = textureLoad(view_output, global_id.xy); | ||
| pixel_color += vec4(radiance, 0.0); | ||
| textureStore(view_output, global_id.xy, pixel_color); | ||
|
|
||
| #ifdef VISUALIZE_WORLD_CACHE | ||
| textureStore(view_output, global_id.xy, vec4(query_world_cache(surface.world_position, surface.world_normal, view.world_position, &rng) * view.exposure, 1.0)); | ||
| #endif | ||
| } | ||
|
|
||
| fn trace_glossy_path(initial_ray_origin: vec3<f32>, initial_wi: vec3<f32>, rng: ptr<function, u32>) -> vec3<f32> { | ||
| var ray_origin = initial_ray_origin; | ||
| var wi = initial_wi; | ||
|
|
||
| // Trace up to three bounces, getting the net throughput from them | ||
| var radiance = vec3(0.0); | ||
| var throughput = vec3(1.0); | ||
| for (var i = 0u; i < 3u; i += 1u) { | ||
| // Trace ray | ||
| let ray = trace_ray(ray_origin, wi, RAY_T_MIN, RAY_T_MAX, RAY_FLAG_NONE); | ||
| if ray.kind == RAY_QUERY_INTERSECTION_NONE { break; } | ||
| let ray_hit = resolve_ray_hit_full(ray); | ||
|
|
||
| // Add world cache contribution | ||
| let diffuse_brdf = ray_hit.material.base_color / PI; | ||
| radiance += throughput * diffuse_brdf * query_world_cache(ray_hit.world_position, ray_hit.geometric_world_normal, view.world_position, rng); | ||
|
|
||
| // Surface is very rough, terminate path in the world cache | ||
| if ray_hit.material.roughness > 0.04 || i == 2u { | ||
| let diffuse_brdf = ray_hit.material.base_color / PI; | ||
| return throughput * diffuse_brdf * query_world_cache(ray_hit.world_position, ray_hit.geometric_world_normal, view.world_position); | ||
| } | ||
| if ray_hit.material.roughness > 0.1 && i != 0u { break; } | ||
|
|
||
| // Sample new ray direction from the GGX BRDF for next bounce | ||
| let TBN = calculate_tbn_mikktspace(ray_hit.world_normal, ray_hit.world_tangent); | ||
|
|
@@ -93,11 +99,11 @@ fn trace_glossy_path(initial_ray_origin: vec3<f32>, initial_wi: vec3<f32>, rng: | |
| // Update throughput for next bounce | ||
| let pdf = ggx_vndf_pdf(wo_tangent, wi_tangent, ray_hit.material.roughness); | ||
| let brdf = evaluate_brdf(N, wo, wi, ray_hit.material); | ||
| let cos_theta = dot(wi, N); | ||
| let cos_theta = saturate(dot(wi, N)); | ||
| throughput *= (brdf * cos_theta) / pdf; | ||
| } | ||
|
|
||
| return vec3(0.0); | ||
| return radiance; | ||
| } | ||
|
|
||
| // Don't adjust the size of this struct without also adjusting GI_RESERVOIR_STRUCT_SIZE. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the perf difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, couldn't get bistro setup properly to test :(