diff --git a/source/MaterialXGenMdl/mdl/materialx/pbrlib.mdl b/source/MaterialXGenMdl/mdl/materialx/pbrlib.mdl index f218f520d3..baf5d3c132 100644 --- a/source/MaterialXGenMdl/mdl/materialx/pbrlib.mdl +++ b/source/MaterialXGenMdl/mdl/materialx/pbrlib.mdl @@ -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