Skip to content

Change MX conductor to sample bounded visible normals#2000

Merged
aconty merged 1 commit into
AcademySoftwareFoundation:mainfrom
aconty:libbsdl
Jun 15, 2025
Merged

Change MX conductor to sample bounded visible normals#2000
aconty merged 1 commit into
AcademySoftwareFoundation:mainfrom
aconty:libbsdl

Conversation

@aconty

@aconty aconty commented Jun 12, 2025

Copy link
Copy Markdown
Contributor

Change MX conductor to sample bounded visible normals

Turquin style multiple scattering is very simple, but also way noiser
than using a diffuse lobe for MS. This is because sampling microfacets
for reflection, the way we do now, is far from ideal at high roughnesses.

Switching to the reflection optimized sampling technique from "Bounded
VNDF Sampling for Smith–GGX Reflections" fixes all the trouble. This
sampling avoids sampling micronormals that are going to reflect the ray
under the surface (and therefore throwing away samples).

Paper:
https://gpuopen.com/download/publications/Bounded_VNDF_Sampling_for_Smith-GGX_Reflections.pdf

Tests

Here is a 64 rpp comparison between the two methods. This is main with Turquin style

old_vd8

and the SPI method with diffuse MS

new_vd8

And to compare the look difference here is a more converged couple of renders

Turquin

old2_vd8

SPI

new2_vd8

In the end the fix is using bounded viseble normals. See comments.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format v17 before submitting, I definitely will look at
    the CI test that runs clang-format and fix anything that it highlights as
    being nonconforming.

@fpsunflower

Copy link
Copy Markdown
Contributor

Its a good point that in many case you are sampling specular + diffuse anyway -- so the non-reciprocal version which adds a diffuse lobe can be obtained almost "for free" (although Turquin's approach is even more free in the sense that its simply a rescaling of the specular lobe).

However in the BSDL framework, the specular and diffuse lobes are not merged, so you can't easily take advantage of this and end up doing specular + diffuse_ms + diffuse which limits the benefit a little. Also, in practice you probably want the diffuse energy compensation lobe to be tagged as part of the specular lobe for the AOV tracking (again limiting the benefit of lobe sharing).

I haven't checked, but is the sampling of the GGX lobe taking advantage of the latest importance sampling scheme for GGX? https://gpuopen.com/download/publications/Bounded_VNDF_Sampling_for_Smith-GGX_Reflections.pdf

I had not noticed a big difference in sampling quality between the approaches in my tests, but I should repeat those experiments to confirm. Intuitively, most of the waste in Turquin's approach comes from the wasted samples after reflection of the visible micronormal. Adding a diffuse lobe will counter this a bit, but fixing this problem more directly as in the paper above should also help.

@selfshadow

Copy link
Copy Markdown

@aconty: this may be faulty intuition on my part but I'm surprised by the noise difference for the leftmost shader balls in the 64 sample renders. What roughness value is that? I would've expected very little visual difference (and negligible multiple scattering) in that case.

@aconty

aconty commented Jun 14, 2025

Copy link
Copy Markdown
Contributor Author

That would be the roughness regularization. Roughness is 0 on the left, but as soon as you have a diffuse bounce roughness goes to 1.0. I guess a depth=1 render be less confusing.

Turquin style multiple scattering is very simple, but also way noiser
than using a diffuse lobe for MS. This is because sampling microfacets
for reflection, the way we do now, is far from ideal at high roughnesses.

Switching to the reflection optimized sampling technique from "Bounded
VNDF Sampling for Smith–GGX Reflections" fixes all the trouble. This
sampling avoids sampling micronormals that are going to reflect the ray
under the surface (and therefore throwing away samples).

Paper:
https://gpuopen.com/download/publications/Bounded_VNDF_Sampling_for_Smith-GGX_Reflections.pdf

Signed-off-by: Alejandro Conty <aconty@imageworks.com>
@aconty

aconty commented Jun 14, 2025

Copy link
Copy Markdown
Contributor Author

Chris was 100% on point, improving the sampling with that paper fixes everything. It is now clean and the lost saturation was due to sample clamps. It is now back. 64rpp render

bnd_vd8

I rephrased and updated this pull reques.

@selfshadow

selfshadow commented Jun 14, 2025

Copy link
Copy Markdown

That would be the roughness regularization.

Oh! That makes perfect sense then.

Chris was 100% on point, improving the sampling with that paper fixes everything.

Awesome!

I rephrased and updated this pull reques.

The PR title is still referring to the original change. Would it make sense to update that?

@aconty aconty changed the title Switch MX conductor to spi way for MS Change MX conductor to sample bounded visible normals Jun 14, 2025
@aconty

aconty commented Jun 14, 2025

Copy link
Copy Markdown
Contributor Author

Updated, is it better now?

@selfshadow

Copy link
Copy Markdown

Updated, is it better now?

Yup, all good now. Thanks!

@fpsunflower fpsunflower left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

You may want to update other microfacet based bsdfs with the same sampling. For the non-reflected case, the sampling over spherical caps is also a bit cheaper so is worth updating too. (fine for a separate review of course)

@aconty
aconty merged commit 87f71d1 into AcademySoftwareFoundation:main Jun 15, 2025
26 checks passed
@lgritz lgritz added the testshade / testrender testrender or testshade sample applications and test harnesses label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testshade / testrender testrender or testshade sample applications and test harnesses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants