Skip to content

Add GLSL functions for PDFs#2779

Merged
jstone-lucasfilm merged 4 commits intoAcademySoftwareFoundation:mainfrom
jstone-lucasfilm:dev_bsdf_refactor
Feb 19, 2026
Merged

Add GLSL functions for PDFs#2779
jstone-lucasfilm merged 4 commits intoAcademySoftwareFoundation:mainfrom
jstone-lucasfilm:dev_bsdf_refactor

Conversation

@jstone-lucasfilm
Copy link
Copy Markdown
Member

This changelist adds explicit GLSL functions for PDFs (probability density functions) to MaterialX, making its physically based shading code clearer and more self-documenting, and providing a stepping stone towards future use of generated GLSL/ESSL/MSL in path tracers as well as rasterization renderers.

This changelist adds explicit GLSL functions for PDFs (probability density functions) to MaterialX, making its physically based shading code clearer and more self-documenting, and providing a stepping stone towards future use of generated GLSL/ESSL/MSL in path tracers as well as rasterization renderers.
Following up on a conversation with Stephen Hill, this update clarifies the name and description of `mx_ggx_VNDF_reflection_PDF`, which represents the PDF of a reflection direction sampled from the GGX VNDF.
// uniform_pdf = 1 / (2 * PI)
// radiance = reflectance * NdotL / uniform_pdf;
radiance += reflectance * NdotL * 2.0 * M_PI;
radiance += reflectance * NdotL / mx_uniform_hemisphere_PDF();
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.

I guess this new division is easy for the compiler to remove since the PDF function returns a constant.

Copy link
Copy Markdown
Contributor

@niklasharrysson niklasharrysson left a comment

Choose a reason for hiding this comment

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

This looks good to me!

Copy link
Copy Markdown
Contributor

@shill-lucasfilm shill-lucasfilm left a comment

Choose a reason for hiding this comment

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

As discussed offline, we should probably add a mx_ggx_VNDF_PDF() function that directly corresponds to the sampling function (which maybe mx_generate_prefilter_env() could use, since unlike mx_environment_radiance(), it's not performance critical), and also update a few functions to handle anisotropy correctly. However, those changes are out of scope for this PR, so I'll prep a new one soon.

@jstone-lucasfilm jstone-lucasfilm merged commit 8d792db into AcademySoftwareFoundation:main Feb 19, 2026
33 checks passed
@jstone-lucasfilm jstone-lucasfilm deleted the dev_bsdf_refactor branch February 19, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants