Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion documents/Specification/MaterialX.PBRSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ If the `edf` input is left unconnected, no emission will occur from the surface.
|`thin_walled`|Set to true to make the surface thin-walled |boolean |false |
|`out` |Output: the computed surface shader |surfaceshader| |

In the equations below, the `bsdf` input corresponds to $f$, the `edf` input corresponds to $L_e$, and the `opacity` input corresponds to $O$.
In the equations below, the `bsdf` input corresponds to $f$, the `edf` input corresponds to $L_e$, and the cutout opacity is $O = \mathrm{clamp}(\mathrm{opacity}, 0, 1)$. Input values below 0 are treated as 0, and input values above 1 are treated as 1, before the surface shader is constructed.

#### Surface Shading Equation

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 @@ -243,7 +243,7 @@
<nodedef name="ND_surface" node="surface" nodegroup="pbr" doc="A constructor node for the surfaceshader type.">
<input name="bsdf" type="BSDF" value="" doc="Distribution function for surface scattering." />
<input name="edf" type="EDF" value="" doc="Distribution function for surface emission." />
<input name="opacity" type="float" value="1.0" doc="Surface cutout opacity" />
<input name="opacity" type="float" value="1.0" uimin="0.0" uimax="1.0" doc="Surface cutout opacity, clamped to the range [0, 1]." />
<input name="thin_walled" type="boolean" value="false" uniform="true" doc="Option to make the surface thin-walled." />
<output name="out" type="surfaceshader" />
</nodedef>
Expand Down
3 changes: 2 additions & 1 deletion source/MaterialXGenHw/Nodes/HwSurfaceNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ void HwSurfaceNode::emitFunctionCall(const ShaderNode& node, GenContext& context
if (const ShaderNode* bsdf = bsdfInput->getConnectedSibling())
{
shadergen.emitLineBegin(stage);
shadergen.emitString("float surfaceOpacity = ", stage);
shadergen.emitString("float surfaceOpacity = clamp(", stage);
shadergen.emitInput(node.getInput(getOpacityInputName()), context, stage);
shadergen.emitString(", 0.0, 1.0)", stage);
shadergen.emitLineEnd(stage);
shadergen.emitLineBreak(stage);

Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMdl/mdl/materialx/pbrlib_1_6.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ export material mx_surface(
ior: mxp_transmission_ior > 0.0 ? color(mxp_transmission_ior) : mxp_bsdf.ior,
volume: bsdf_volume,
geometry: material_geometry(
cutout_opacity: mxp_opacity
cutout_opacity: math::clamp(mxp_opacity, 0.0, 1.0)
)
);

Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXGenMdl/mdl/materialx/pbrlib_1_9.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,6 @@ export material mx_surface(
ior: mxp_transmission_ior > 0.0 ? color(mxp_transmission_ior) : mxp_bsdf.ior,
volume: bsdf_volume,
geometry: material_geometry(
cutout_opacity: mxp_opacity
cutout_opacity: math::clamp(mxp_opacity, 0.0, 1.0)
)
);
Loading