Skip to content
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

Update specular BRDF for image-based lighting #12083

Merged
merged 4 commits into from
Jul 22, 2024
Merged

Update specular BRDF for image-based lighting #12083

merged 4 commits into from
Jul 22, 2024

Conversation

jjhembd
Copy link
Contributor

@jjhembd jjhembd commented Jul 13, 2024

Merge #12082 first!

Description

This PR updates the specular calculations for image-based lighting.

Key changes

Use perceptual roughness

The raw "perceptual" roughness as encoded in the glTF is now retained in MaterialStageFS. Where the squared "alpha" roughness is needed (e.g. for direct lighting), it is squared when used, and more consistently named "alphaRoughness" for clarity.

This change to un-squared roughness is significant for the rendering result in two places:

  • Selecting the LOD of the environment map, from which the incident specular radiance is sampled
  • Computing the surface "bent normal" for determining the specular incident angle in anisotropic materials

Update self-shadowing function in BRDF look-up texture

Image-based lighting uses a pre-computed texture from which BRDF parameters are read. The calculation of these parameters includes a self-shadowing function. This PR updates the self-shadowing function to be consistent with the one used for direct lighting, as implemented in #12063.

Fix clamping errors

MaterialStageFS was clamping roughness to a minimum of 0.04. This has been removed, to allow sharper reflections on materials like the Clearcoat Car Paint test model.

Also, in ImageBasedLightingStageFS, the calculation of NdotV for specular IBL calculation applied an abs for negative values. This has been updated to a clamp(NdotV, 0.0, 1.0).

Rendering comparisons

Clearcoat Wicker, before
image

Clearcoat Wicker, after
image
Note the brighter and broader specular reflection.

Barn Lamp, before
image

Barn Lamp, after
image
Note the more natural appearance of the brushed metal.

Clearcoat Test, before
image

Clearcoat Test, after
image
Note the improved clarity of the "Roughness variations", now that we are using perceptual roughness. Also note the changed appearance of the "Partial coating" after fixing the clamp of NdotV.

Issue number and link

Addresses part of #12028.

Testing plan

Load the "glTF PBR Extensions" and "Image Based Lighting" Sandcastles, and compare the rendering to the main branch.

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • [ ] I have added or updated unit tests to ensure consistent code coverage See Add screenshot testing for subtle lighting changes #12065
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

Copy link

Thank you for the pull request, @jjhembd!

✅ We can confirm we have a CLA on file for you.

@ggetz
Copy link
Contributor

ggetz commented Jul 16, 2024

@jjhembd Fantastic, these look a lot closer to the glTF sample viewer which is good for consistency across the ecosystem.

Offline we chatted about some potential issues with the mipmap sampling that was exposed by the updates to this PR. Can you write up an issue if necessary, and let me know when this PR is good to go?

@jjhembd
Copy link
Contributor Author

jjhembd commented Jul 22, 2024

Thanks @ggetz!

some potential issues with the mipmap sampling that was exposed by the updates to this PR. Can you write up an issue if necessary

I opened #12090 to discuss the mipmap sampling. This PR should be ready to go.

@ggetz
Copy link
Contributor

ggetz commented Jul 22, 2024

Great, thanks @jjhembd!

@ggetz ggetz merged commit e498bf1 into main Jul 22, 2024
9 checks passed
@ggetz ggetz deleted the ibl-roughness branch July 22, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants