Skip to content

Commit

Permalink
Add MDL implementation for mx_subsurface_bsdf (#1053)
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek-Nvidia committed Aug 21, 2022
1 parent 6745af3 commit 322bf9b
Showing 1 changed file with 36 additions and 2 deletions.
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

0 comments on commit 322bf9b

Please sign in to comment.