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

Add color82 to generalized_schlick_bsdf #1727

Conversation

jstone-lucasfilm
Copy link
Member

@jstone-lucasfilm jstone-lucasfilm commented Mar 4, 2024

This changelist adds a color82 input to the generalized_schlick_bsdf node in MaterialX, with a full implementation in hardware shading languages (GLSL/MSL/ESSL) and simple fallback behavior in closure-based shading languages (OSL/MDL).

The real-time implementation is based on Naty Hoffman's generalization of Adobe Fresnel (https://renderwonk.com/publications/wp-generalization-adobe/gen-adobe.pdf), which is visually consistent with previous versions of generalized_schlick_bsdf when color82 is left at its default setting.

@jstone-lucasfilm
Copy link
Member Author

Generalized Schlick BSDF with white color82:
GeneralizedSchlickBSDF_Color82_White

Generalized Schlick BSDF with gold color82:
GeneralizedSchlickBSDF_Color82_Gold

Generalized Schlick BSDF with blue color82:
GeneralizedSchlickBSDF_Color82_Blue

vec3 mx_fresnel_hoffman_schlick(float cosTheta, vec3 F0, vec3 F82, vec3 F90, float exponent)
{
const float COS_THETA_MAX = 1.0 / 7.0;
const float COS_THETA_FACTOR = 1.0 / (COS_THETA_MAX * pow(1.0 - COS_THETA_MAX, 6.0));
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency you could use the added mx_pow6 function here as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good note, @niklasharrysson, and I had wanted to use the approach you describe, but some GLSL compilers require that a const value be defined entirely in terms of constant expressions.

So I actually see a compile-time error in my GLSL environment if I use the non-const mx_pow6 as a sub-expression of COS_THETA_FACTOR.

For simplicity, I went back to using the built-in pow function, but there may be a more clever way of notating mx_pow6 so that it can also be used in this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that's fine, this was just a tiny thing I noticed.

@niklasharrysson
Copy link
Contributor

This looks good to me @jstone-lucasfilm, and I only had a nitpick comment above.

This changelist adds a color82 input to the generalized_schlick_bsdf node in MaterialX, with a full implementation in hardware shading languages (GLSL/MSL/ESSL) and simple fallback behavior in closure-based shading languages (OSL/MDL).

The real-time implementation is based on Naty Hoffman's generalization of Adobe Fresnel (https://renderwonk.com/publications/wp-generalization-adobe/gen-adobe.pdf), which is visually consistent with previous versions of generalized_schlick_bsdf when color82 is left at its default setting.
@jstone-lucasfilm jstone-lucasfilm merged commit cb9a99d into AcademySoftwareFoundation:dev_1.39 Mar 7, 2024
61 checks passed
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.

2 participants