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 MDL implementation for mx_subsurface_bsdf #1053

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions source/MaterialXGenMdl/mdl/materialx/pbrlib.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,42 @@ export material mx_subsurface_bsdf(
) [[
anno::usage( "materialx:bsdf")
]]
// TODO: add proper implementation
= material();
= let {
// https://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_slides_v2.pdf
// Phase function eccentricity 'g' has been omitted here since we pass that directly
// to anisotropic_vdf(directional_bias: g).
color albedo = color(4.09712) +
(4.20863f * mxp_color) -
math::sqrt(
9.59217f +
41.6808f * mxp_color +
17.7126f * mxp_color * mxp_color);

color albedo_sq = albedo * albedo;

color white = color(1.0, 1.0, 1.0);

color alpha =
(white - albedo_sq) / (white - mxp_anisotropy * albedo_sq);

color radius_inv = white/mxp_radius;

color sigma_s = alpha * radius_inv;
color sigma_a = radius_inv - sigma_s;

} in material(
volume: material_volume(
scattering: df::anisotropic_vdf (
directional_bias: mxp_anisotropy
),
scattering_coefficient: sigma_s,
absorption_coefficient: sigma_a
),

surface: material_surface(
scattering: df::diffuse_transmission_bsdf(tint: white)
)
);

// TODO: MDL's sheen BSDF has no possibility to configure the base BSDF, it is
// always a diffuse BSDF. Its color is configurable through the multiscatter
Expand Down