Skip to content

Commit

Permalink
Change subsurface_bsdf radius from vector3 to color3
Browse files Browse the repository at this point in the history
  • Loading branch information
pablode committed May 24, 2024
1 parent d3637cd commit 2b97826
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 26 deletions.
13 changes: 5 additions & 8 deletions libraries/bxdf/lama/lama_sss.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,20 @@
<nodegraph name="IMPL_lama_sss" nodedef="ND_lama_sss">

<!-- DMFP -->
<convert name="subsurface_radius_vector" type="vector3">
<input name="in" type="color3" interfacename="sssRadius" />
</convert>
<multiply name="subsurface_radius_scaled" type="vector3">
<input name="in1" type="vector3" nodename="subsurface_radius_vector" />
<multiply name="subsurface_radius_scaled" type="color3">
<input name="in1" type="color3" interfacename="sssRadius" />
<input name="in2" type="float" interfacename="sssScale" />
</multiply>
<multiply name="subsurface_multiply_unitlength" type="vector3">
<input name="in1" type="vector3" nodename="subsurface_radius_scaled" />
<multiply name="subsurface_multiply_unitlength" type="color3">
<input name="in1" type="color3" nodename="subsurface_radius_scaled" />
<input name="in2" type="float" interfacename="sssUnitLength" />
</multiply>

<!-- BRDF -->
<subsurface_bsdf name="subsurface_bsdf" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="color" type="color3" interfacename="color" />
<input name="radius" type="vector3" nodename="subsurface_multiply_unitlength" />
<input name="radius" type="color3" nodename="subsurface_multiply_unitlength" />
<input name="anisotropy" type="float" interfacename="sssAnisotropy" />
<input name="normal" type="vector3" interfacename="normal" />
</subsurface_bsdf>
Expand Down
9 changes: 3 additions & 6 deletions libraries/bxdf/open_pbr_surface.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,13 @@
</mix>

<!-- Subsurface (non-thin-walled) -->
<convert name="subsurface_radius_vector" type="vector3">
<input name="in" type="color3" interfacename="subsurface_radius_scale" />
</convert>
<multiply name="subsurface_radius_scaled" type="vector3">
<input name="in1" type="vector3" nodename="subsurface_radius_vector" />
<multiply name="subsurface_radius_scaled" type="color3">
<input name="in1" type="color3" interfacename="subsurface_radius_scale" />
<input name="in2" type="float" interfacename="subsurface_radius" />
</multiply>
<subsurface_bsdf name="subsurface_bsdf" type="BSDF">
<input name="color" type="color3" nodename="subsurface_color_nonnegative" />
<input name="radius" type="vector3" nodename="subsurface_radius_scaled" />
<input name="radius" type="color3" nodename="subsurface_radius_scaled" />
<input name="anisotropy" type="float" interfacename="subsurface_scatter_anisotropy" />
<input name="normal" type="vector3" interfacename="geometry_normal" />
</subsurface_bsdf>
Expand Down
9 changes: 3 additions & 6 deletions libraries/bxdf/standard_surface.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,14 @@
<input name="color" type="color3" nodename="coat_affected_subsurface_color" />
<input name="normal" type="vector3" interfacename="normal" />
</translucent_bsdf>
<convert name="subsurface_radius_vector" type="vector3">
<input name="in" type="color3" interfacename="subsurface_radius" />
</convert>
<multiply name="subsurface_radius_scaled" type="vector3">
<input name="in1" type="vector3" nodename="subsurface_radius_vector" />
<multiply name="subsurface_radius_scaled" type="color3">
<input name="in1" type="color3" interfacename="subsurface_radius" />
<input name="in2" type="float" interfacename="subsurface_scale" />
</multiply>
<subsurface_bsdf name="subsurface_bsdf" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="color" type="color3" nodename="coat_affected_subsurface_color" />
<input name="radius" type="vector3" nodename="subsurface_radius_scaled" />
<input name="radius" type="color3" nodename="subsurface_radius_scaled" />
<input name="anisotropy" type="float" interfacename="subsurface_anisotropy" />
<input name="normal" type="vector3" interfacename="normal" />
</subsurface_bsdf>
Expand Down
2 changes: 1 addition & 1 deletion libraries/pbrlib/genosl/legacy/mx_subsurface_bsdf.osl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
void mx_subsurface_bsdf(float weight, color _color, vector radius, float anisotropy, normal N, output BSDF bsdf)
void mx_subsurface_bsdf(float weight, color _color, color radius, float anisotropy, normal N, output BSDF bsdf)
{
// TODO: Subsurface closure is not supported by vanilla OSL.
bsdf.response = _color * weight * diffuse(N);
Expand Down
2 changes: 1 addition & 1 deletion libraries/pbrlib/genosl/mx_subsurface_bsdf.osl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
void mx_subsurface_bsdf(float weight, color _color, vector radius, float anisotropy, normal N, output BSDF bsdf)
void mx_subsurface_bsdf(float weight, color _color, color radius, float anisotropy, normal N, output BSDF bsdf)
{
// TODO: Subsurface closure is not supported by vanilla OSL.
bsdf = _color * weight * diffuse(N);
Expand Down
2 changes: 1 addition & 1 deletion libraries/pbrlib/pbrlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<nodedef name="ND_subsurface_bsdf" node="subsurface_bsdf" bsdf="R" nodegroup="pbr" doc="A subsurface scattering BSDF for true subsurface scattering.">
<input name="weight" type="float" value="1.0" uimin="0.0" uimax="1.0" />
<input name="color" type="color3" value="0.18, 0.18, 0.18" />
<input name="radius" type="vector3" value="1.0, 1.0, 1.0" />
<input name="radius" type="color3" value="1.0, 1.0, 1.0" />
<input name="anisotropy" type="float" value="0.0" />
<input name="normal" type="vector3" defaultgeomprop="Nworld" />
<output name="out" type="BSDF" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<subsurface_bsdf name="subsurface_brdf1" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="color" type="color3" value="0.18, 0.18, 0.18" />
<input name="radius" type="vector3" value="1.0, 1.0, 1.0" />
<input name="radius" type="color3" value="1.0, 1.0, 1.0" />
<input name="anisotropy" type="float" value="0.0" />
<input name="normal" type="vector3" value="0.0, 0.0, 0.0" />
</subsurface_bsdf>
Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXGenMdl/mdl/materialx/pbrlib_1_6.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export material mx_generalized_schlick_bsdf(
export material mx_subsurface_bsdf(
float mxp_weight = 1.0 [[ anno::unused() ]],
color mxp_color = color(0.18),
float3 mxp_radius = float3(1.0), // TODO: should probably be a color in MTLX Spec
color mxp_radius = color(1.0),
float mxp_anisotropy = 0.0,
float3 mxp_normal = state::normal() [[ anno::unused() ]]
) [[
Expand All @@ -357,7 +357,7 @@ export material mx_subsurface_bsdf(
color alpha =
(white - albedo_sq) / (white - mxp_anisotropy * albedo_sq);

color radius_inv = white/color(mxp_radius);
color radius_inv = white / mxp_radius;

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

0 comments on commit 2b97826

Please sign in to comment.