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

Initial refraction approximation in GLSL #918

Merged
merged 3 commits into from Apr 25, 2022
Merged

Initial refraction approximation in GLSL #918

merged 3 commits into from Apr 25, 2022

Conversation

jstone-lucasfilm
Copy link
Member

This changelist introduces a rough approximation of refraction in GLSL, allowing transmissive materials such as glass to respond visually to changes in specular_IOR, specular_roughness, and transmission_color.

Because this initial approximation is limited to a single render pass, only the environment radiance map is currently visible in refractions, and opaque objects behind transmissive surfaces are not yet visible.

This changelist introduces a rough approximation of refraction in GLSL, allowing transmissive materials such as glass to respond visually to changes in specular_IOR, specular_roughness, and transmission_color.

Because this initial approximation is limited to a single render pass, only the environment radiance map is currently visible in refractions, and opaque objects behind transmissive surfaces are not yet visible.
@jstone-lucasfilm
Copy link
Member Author

The following renders are from MaterialXView, showing the proposed refraction approximation in the context of transmissive Standard Surface materials:

Standard Surface Glass:
StandardSurfaceGlass_GlslRefraction

Standard Surface Glass Tinted:
StandardSurfaceTintedGlass_GlslRefraction

@jstone-lucasfilm
Copy link
Member Author

Thanks to @mjyip-lucasfilm for her significant contributions to this work!

@jstone-lucasfilm
Copy link
Member Author

Reference renders in GLSL and OSL:

ReferenceRender_04_20_2022.pdf

@@ -34,7 +34,7 @@ vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distributio

// Compute the half vector and incoming light direction.
vec3 H = mx_ggx_importance_sample_NDF(Xi, alpha);
vec3 L = -reflect(V, H);
vec3 L = fd.refraction ? mx_refraction_solid_sphere(-V, H, fd.ior.x) : -reflect(V, H);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note for the future that we need to split this switch in two later to support thin-walled materials. We then need to have separate control of transmission and refraction on/off, since we can have transmission without refraction in that case, but still transmission with a roughness.

// glossy environment map refraction, ignoring any scene geometry that
// might be visible through the surface.
fd.refraction = true;
vec3 Li = $refractionEnv ? mx_environment_radiance(N, V, X, safeAlpha, distribution, fd) : $refractionColor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity why is there an option to replace the refracted environment with a uniform color? We don't have a corresponding control for environment reflections. Or is this just for debugging for now?

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 option was primarily added for our GLSL/OSL reference renders, since OSL testrender refracts the constant-color background instead of the distant environment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha! Maybe we should fix this so the environment is visible in both reflection and transmission, for both GLSL and OSL test suite rendering. Lets do that in a separate PR though.

Copy link
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.

Looks great @jstone-lucasfilm. I only had some minor comments above.

@jstone-lucasfilm jstone-lucasfilm merged commit f5fc395 into AcademySoftwareFoundation:main Apr 25, 2022
Michaelredaa pushed a commit to Michaelredaa/MaterialX that referenced this pull request Oct 21, 2023
This changelist introduces a rough approximation of refraction in GLSL, allowing transmissive materials such as glass to respond visually to changes in specular_IOR, specular_roughness, and transmission_color.

Because this initial approximation is limited to a single render pass, only the environment radiance map is currently visible in refractions, and opaque objects behind transmissive surfaces are not yet visible.
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.

None yet

2 participants