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
24 changes: 23 additions & 1 deletion libraries/bxdf/usd_preview_surface.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@
<output name="out" type="surfaceshader" />
</nodedef>

<nodedef name="ND_UsdPreviewSurface_surfaceshader_261" node="UsdPreviewSurface" nodegroup="pbr" doc="UsdPreviewSurface shader" version="2.6" isdefaultversion="true">
<input name="diffuseColor" type="color3" value="0.18, 0.18, 0.18" uimin="0,0,0" uimax="1,1,1" uiname="Diffuse Color" />
<input name="emissiveColor" type="color3" value="0, 0, 0" uimin="0,0,0" uisoftmax="1,1,1" uiname="Emissive Color" />
<input name="useSpecularWorkflow" type="integer" value="0" uimin="0" uimax="1" uistep="1" uiname="Use Specular Workflow" />
<input name="specularColor" type="color3" value="0, 0, 0" uimin="0,0,0" uimax="1,1,1" uiname="Specular Color" />
<input name="metallic" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Metallic" />
<input name="roughness" type="float" value="0.5" uimin="0.0" uimax="1.0" uiname="Roughness" />
<input name="clearcoat" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Clearcoat" />
<input name="clearcoatRoughness" type="float" value="0.01" uimin="0.0" uimax="1.0" uiname="Clearcoat Roughness" />
<input name="opacity" type="float" value="1" uimin="0.0" uimax="1.0" uiname="Opacity" />
<input name="opacityMode" type="string" enum="transparent,presence" value="transparent" uiname="Opacity Mode" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be made to have an enumvalues attribute. For consistency + to make mapping explicit for hardware. "0, 1" area probably fine. Thx.

<input name="opacityThreshold" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Opacity Threshold" />
<input name="ior" type="float" value="1.5" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Index of Refraction" />
<input name="normal" type="vector3" value="0, 0, 1" uimin="-1.0,-1.0,-1.0" uimax="1.0,1.0,1.0" uiname="Normal" />
<input name="displacement" type="float" value="0" uiname="Displacement" />
<input name="occlusion" type="float" value="1" uimin="0.0" uimax="1.0" uiname="Occlusion" />
<output name="out" type="surfaceshader" />
</nodedef>

<!-- Node: UsdUVTexture -->
<nodedef name="ND_UsdUVTexture" node="UsdUVTexture" nodegroup="texture2d" version="2.2" inherit="ND_UsdUVTexture_23">
<output name="r" type="float" />
Expand Down Expand Up @@ -112,8 +131,11 @@
<!-- USD Preview Surface nodegraph implementations -->
<!-- ======================================================================== -->

<implementation name="IMP_UsdPreviewSurface_surfaceshader" nodedef="ND_UsdPreviewSurface_surfaceshader" nodegraph="NG_UsdPreviewSurface_surfaceshader" />
<implementation name="IMP_UsdPreviewSurface_surfaceshader_261" nodedef="ND_UsdPreviewSurface_surfaceshader_261" nodegraph="NG_UsdPreviewSurface_surfaceshader" />

<!-- Node: UsdPreviewSurface -->
<nodegraph name="IMP_UsdPreviewSurface_surfaceshader" nodedef="ND_UsdPreviewSurface_surfaceshader">
<nodegraph name="NG_UsdPreviewSurface_surfaceshader" >

<convert name="use_specular_workflow_float" type="float">
<input name="in" type="integer" interfacename="useSpecularWorkflow" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<materialx version="1.39" colorspace="lin_rec709">

<UsdPreviewSurface name="SR_USD_opacityMode_transparent_int" type="surfaceshader">
<input name="diffuseColor" type="color3" value="0.0518895, 0.29606, 0.425324" />
<input name="roughness" type="float" value="0.4" />
<input name="clearcoat" type="float" value="1" />
<input name="clearcoatRoughness" type="float" value="0" />
<input name="opacity" type="float" value="0.2" />
<input name="opacityMode" type="integer" value="0" /> <!-- transparent -->
</UsdPreviewSurface>
<surfacematerial name="USD_opacityMode_transparent_int" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="SR_USD_opacityMode_transparent_int" />
</surfacematerial>

<UsdPreviewSurface name="SR_USD_opacityMode_presence_int" type="surfaceshader">
<input name="diffuseColor" type="color3" value="0.0518895, 0.29606, 0.425324" />
<input name="roughness" type="float" value="0.4" />
<input name="clearcoat" type="float" value="1" />
<input name="clearcoatRoughness" type="float" value="0" />
<input name="opacity" type="float" value="0.2" />
<input name="opacityMode" type="integer" value="1" /> <!-- presence -->
</UsdPreviewSurface>
<surfacematerial name="USD_opacityMode_presence_int" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="SR_USD_opacityMode_presence_int" />
</surfacematerial>

<UsdPreviewSurface name="SR_USD_opacityMode_transparent_string" type="surfaceshader">
<input name="diffuseColor" type="color3" value="0.0518895, 0.29606, 0.425324" />
<input name="roughness" type="float" value="0.4" />
<input name="clearcoat" type="float" value="1" />
<input name="clearcoatRoughness" type="float" value="0" />
<input name="opacity" type="float" value="0.2" />
<input name="opacityMode" type="string" value="transparent" />
</UsdPreviewSurface>
<surfacematerial name="USD_opacityMode_transparent_string" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="SR_USD_opacityMode_transparent_string" />
</surfacematerial>

<UsdPreviewSurface name="SR_USD_opacityMode_presence_string" type="surfaceshader">
<input name="diffuseColor" type="color3" value="0.0518895, 0.29606, 0.425324" />
<input name="roughness" type="float" value="0.4" />
<input name="clearcoat" type="float" value="1" />
<input name="clearcoatRoughness" type="float" value="0" />
<input name="opacity" type="float" value="0.2" />
<input name="opacityMode" type="string" value="presence" />
</UsdPreviewSurface>
<surfacematerial name="USD_opacityMode_presence_string" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="SR_USD_opacityMode_presence_string" />
</surfacematerial>

</materialx>
13 changes: 12 additions & 1 deletion source/MaterialXCore/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,18 @@ bool ValueElement::validate(string* message) const
validateRequire(valueElem != nullptr, res, message, "Interface name not found in referenced declaration");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All string enums should resolve to integers for h/w. Is this what you were seeing ? i.e. There should not be type mismatches -- so perhaps a fix is required elsewhere.

if (valueElem)
{
validateRequire(getType() == valueElem->getType(), res, message, "Interface name refers to value element of a different type");
bool typesMatch = getType() == valueElem->getType();
if (!typesMatch)
{
// if the types don't match - we might have an enumeration at the interface.
if (valueElem->getType() == STRING_TYPE_STRING &&
getType() == INTEGER_TYPE_STRING &&
valueElem->hasAttribute(ValueElement::ENUM_ATTRIBUTE))
{
typesMatch = true;
}
}
validateRequire(typesMatch, res, message, "Interface name refers to value element of a different type");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions source/MaterialXCore/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const string DEFAULT_TYPE_STRING = "color3";
const string FILENAME_TYPE_STRING = "filename";
const string GEOMNAME_TYPE_STRING = "geomname";
const string STRING_TYPE_STRING = "string";
const string INTEGER_TYPE_STRING = "integer";
const string BSDF_TYPE_STRING = "BSDF";
const string EDF_TYPE_STRING = "EDF";
const string VDF_TYPE_STRING = "VDF";
Expand Down
1 change: 1 addition & 0 deletions source/MaterialXCore/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern MX_CORE_API const string DEFAULT_TYPE_STRING;
extern MX_CORE_API const string FILENAME_TYPE_STRING;
extern MX_CORE_API const string GEOMNAME_TYPE_STRING;
extern MX_CORE_API const string STRING_TYPE_STRING;
extern MX_CORE_API const string INTEGER_TYPE_STRING;
extern MX_CORE_API const string BSDF_TYPE_STRING;
extern MX_CORE_API const string EDF_TYPE_STRING;
extern MX_CORE_API const string VDF_TYPE_STRING;
Expand Down
Loading