Solari: Improve specular GI#21907
Conversation
|
There's still some weird glowing around the very edges of the monkey, but this is much closer. |
…better-specular-gi
|
@SparkyPotato please review this carefully. I'm not super confident about my MIS code (but the good news is that implementing it myself, I have a bunch better understanding now). |
| const DIFFUSE_GI_REUSE_ROUGHNESS_THRESHOLD: f32 = 0.4; | ||
| const WORLD_CACHE_TERMINATION_ROUGHNESS_THRESHOLD: f32 = 0.4; |
There was a problem hiding this comment.
This threshold is below an input perceptual roughness of 0.63, which seems really high.
There was a problem hiding this comment.
It was based on a bunch of testing. 0.4 was the threshold where I didn't notice visual artifacts.
It'll eventually be configurable though.
| let wi_tangent = vec3(dot(wi, T), dot(wi, B), dot(wi, N)); | ||
|
|
||
| let p_light = 1.0 / inverse_p_light; | ||
| let p_bounce = max(0.001, ggx_vndf_pdf(wo_tangent, wi_tangent, ray_hit.material.roughness)); |
There was a problem hiding this comment.
This shouldn't actually matter, because even if it were 0, the power heuristic would become p_light^2 / p_light^2 = 1. But this is only called when the surface isn't perfectly specular, so the pdf won't be 0 anyways. Maybe the NaNs you were seeing were related to p_light being 0, that this max also hides (but the output in this case is 0, not 1)?
There was a problem hiding this comment.
Testing shows that ggx_vndf_pdf is the one breaking things. p_light is fine.
Go back to only sampling the world cache for rough and non-first-bounce surfaces, but sample direct lighting when that doesn't happen.
Mainline

This PR

Pathtraced reference

Fixes #21967.