-
Notifications
You must be signed in to change notification settings - Fork 358
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
Initial refraction approximation in GLSL #918
Conversation
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.
Thanks to @mjyip-lucasfilm for her significant contributions to this work! |
Reference renders in GLSL and OSL: |
@@ -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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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.