Skip to content

Commit

Permalink
Merge branch 'AcademySoftwareFoundation:main' into simplify_osl_test_…
Browse files Browse the repository at this point in the history
…setup
  • Loading branch information
ld-kerley authored Aug 2, 2024
2 parents 0c5594f + 1d066bb commit 99452f6
Show file tree
Hide file tree
Showing 8 changed files with 372 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libraries/bxdf/open_pbr_surface.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
doc="Index of refraction of the dielectric base." />
<input name="specular_roughness_anisotropy" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Specular Anisotropy" uifolder="Specular" uiadvanced="true"
doc="The directional bias of the roughness of the metal/dielectric base, resulting in increasingly stretched highlights along the tangent direction." />
<input name="transmission_weight" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Transmission Weight" uifolder="Transmission" uiadvanced="true"
<input name="transmission_weight" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Transmission Weight" uifolder="Transmission" uiadvanced="true" hint="transparency"
doc="Mixture weight between the transparent and opaque dielectric base. The greater the value the more transparent the material." />
<input name="transmission_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Transmission Color" uifolder="Transmission" uiadvanced="true"
doc="Controls color of the transparent base due to Beer's law volumetric absorption under the surface (reverts to a non-physical tint when transmission_depth is zero)." />
Expand Down Expand Up @@ -75,7 +75,7 @@
doc="The amount of emitted light, as a luminance in nits." />
<input name="emission_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Emission Color" uifolder="Emission"
doc="The color of the emitted light." />
<input name="geometry_opacity" type="float" value="1" uimin="0" uimax="1" uiname="Opacity" uifolder="Geometry"
<input name="geometry_opacity" type="float" value="1" uimin="0" uimax="1" uiname="Opacity" uifolder="Geometry" hint="opacity"
doc="The opacity of the entire material." />
<input name="geometry_thin_walled" type="boolean" value="false" uiname="Thin Walled" uifolder="Geometry" uiadvanced="true"
doc="If true the surface is double-sided and represents an infinitesimally thin shell. Suitable for extremely geometrically thin objects such as leaves or paper." />
Expand Down
282 changes: 282 additions & 0 deletions libraries/bxdf/translation/open_pbr_to_standard_surface.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
<?xml version="1.0"?>
<materialx version="1.39">

<nodedef name="ND_open_pbr_surface_to_standard_surface" node="open_pbr_surface_to_standard_surface" nodegroup="translation">
<input name="base_weight" type="float" value="1.0" />
<input name="base_color" type="color3" value="0.8, 0.8, 0.8" />
<input name="base_diffuse_roughness" type="float" value="0.0" />
<input name="base_metalness" type="float" value="0.0" />

<input name="specular_weight" type="float" value="1.0" />
<input name="specular_color" type="color3" value="1, 1, 1" />
<input name="specular_roughness" type="float" value="0.3" />
<input name="specular_ior" type="float" value="1.5" />
<input name="specular_roughness_anisotropy" type="float" value="0.0" />

<input name="transmission_weight" type="float" value="0.0" />
<input name="transmission_color" type="color3" value="1, 1, 1" />
<input name="transmission_depth" type="float" value="0.0" />
<input name="transmission_scatter" type="color3" value="0, 0, 0" />
<input name="transmission_scatter_anisotropy" type="float" value="0.0" />
<input name="transmission_dispersion_scale" type="float" value="0.0" />

<input name="subsurface_weight" type="float" value="0" />
<input name="subsurface_color" type="color3" value="0.8, 0.8, 0.8" />
<input name="subsurface_radius" type="float" value="1.0" />
<input name="subsurface_radius_scale" type="color3" value="1.0, 0.5, 0.25" />
<input name="subsurface_scatter_anisotropy" type="float" value="0.0" />

<input name="fuzz_weight" type="float" value="0.0" />
<input name="fuzz_color" type="color3" value="1, 1, 1" />
<input name="fuzz_roughness" type="float" value="0.5" />

<input name="coat_weight" type="float" value="0.0" />
<input name="coat_color" type="color3" value="1, 1, 1" />
<input name="coat_roughness" type="float" value="0.0" />
<input name="coat_roughness_anisotropy" type="float" value="0.0" />
<input name="coat_ior" type="float" value="1.6" />
<input name="coat_darkening" type="float" value="1.0" />

<input name="thin_film_weight" type="float" value="0" />
<input name="thin_film_thickness" type="float" value="0.5" />
<input name="thin_film_ior" type="float" value="1.4" />

<input name="emission_luminance" type="float" value="0.0" />
<input name="emission_color" type="color3" value="1, 1, 1" />

<input name="geometry_opacity" type="float" value="1" />
<input name="geometry_thin_walled" type="boolean" value="false" />

<!--Outputs-->
<output name="base_out" type="float" />
<output name="base_color_out" type="color3" />
<output name="diffuse_roughness_out" type="float" />
<output name="metalness_out" type="float" />

<output name="specular_out" type="float"/>
<output name="specular_color_out" type="color3" />
<output name="specular_roughness_out" type="float" />
<output name="specular_IOR_out" type="float" />
<output name="specular_anisotropy_out" type="float" />

<output name="transmission_out" type="float" />
<output name="transmission_color_out" type="color3" />
<output name="transmission_depth_out" type="float" />
<output name="transmission_scatter_out" type="color3" />
<output name="transmission_scatter_anisotropy_out" type="float" />
<output name="transmission_dispersion_out" type="float" />

<output name="subsurface_out" type="float" />
<output name="subsurface_color_out" type="color3" />
<output name="subsurface_radius_out" type="color3" />
<output name="subsurface_scale_out" type="float" />
<output name="subsurface_anisotropy_out" type="float" />

<output name="sheen_out" type="float" />
<output name="sheen_color_out" type="color3" />
<output name="sheen_roughness_out" type="float" />

<output name="coat_out" type="float" />
<output name="coat_color_out" type="color3" />
<output name="coat_roughness_out" type="float" />
<output name="coat_anisotropy_out" type="float" />
<output name="coat_IOR_out" type="float" />
<output name="coat_affect_color_out" type="float" />
<output name="coat_affect_roughness_out" type="float" />

<output name="thin_film_thickness_out" type="float" />
<output name="thin_film_IOR_out" type="float" />

<output name="emission_out" type="float" />
<output name="emission_color_out" type="color3" />

<output name="opacity_out" type="color3" />
<output name="thin_walled_out" type="boolean" />
</nodedef>

<nodegraph name="NG_open_pbr_surface_to_standard_surface" nodedef="ND_open_pbr_surface_to_standard_surface">

<!--Base-->
<dot name="base" type="float">
<input name="in" type="float" interfacename="base_weight" />
</dot>
<dot name="baseColor" type="color3">
<input name="in" type="color3" interfacename="base_color" />
</dot>
<dot name="diffuseRoughness" type="float">
<input name="in" type="float" interfacename="base_diffuse_roughness" />
</dot>
<dot name="metalness" type="float">
<input name="in" type="float" interfacename="base_metalness" />
</dot>

<!--Specular-->
<dot name="spec" type="float">
<input name="in" type="float" interfacename="specular_weight" />
</dot>
<dot name="specColor" type="color3">
<input name="in" type="color3" interfacename="specular_color" />
</dot>
<mix name="specRoughness" type="float">
<input name="fg" type="float" interfacename="coat_roughness" />
<input name="bg" type="float" interfacename="specular_roughness" />
<input name="mix" type="float" interfacename="coat_weight" />
</mix>
<dot name="specIOR" type="float">
<input name="in" type="float" interfacename="specular_ior" />
</dot>
<!-- logic for anisotropic specular is noticeably different between Standard Surface and OpenPBR, so the translation between these concepts will take more thought-->
<dot name="specAnisotropy" type="float">
<input name="in" type="float" interfacename="specular_roughness_anisotropy" />
</dot>

<!--Transmission-->
<dot name="transmission" type="float">
<input name="in" type="float" interfacename="transmission_weight" />
</dot>
<dot name="transmissionColor" type="color3">
<input name="in" type="color3" interfacename="transmission_color" />
</dot>
<dot name="transmissionDepth" type="float">
<input name="in" type="float" interfacename="transmission_depth" />
</dot>
<dot name="transmissionScatter" type="color3">
<input name="in" type="color3" interfacename="transmission_scatter" />
</dot>
<dot name="transmissionScatterAnisotropy" type="float">
<input name="in" type="float" interfacename="transmission_scatter_anisotropy" />
</dot>
<dot name="transmissionDispersion" type="float">
<input name="in" type="float" interfacename="transmission_dispersion_scale" />
</dot>

<!--Subsurface-->
<dot name="subsurface" type="float">
<input name="in" type="float" interfacename="subsurface_weight" />
</dot>
<dot name="subsurfaceColor" type="color3">
<input name="in" type="color3" interfacename="subsurface_color" />
</dot>
<dot name="subsurfaceScale" type="float">
<input name="in" type="float" interfacename="subsurface_radius" />
</dot>
<dot name="subsurfaceRadius" type="color3">
<input name="in" type="color3" interfacename="subsurface_radius_scale" />
</dot>
<dot name="subsurfaceAnisotropy" type="float">
<input name="in" type="float" interfacename="subsurface_scatter_anisotropy" />
</dot>

<!--Sheen-->
<dot name="sheen" type="float">
<input name="in" type="float" interfacename="fuzz_weight" />
</dot>
<dot name="sheenColor" type="color3">
<input name="in" type="color3" interfacename="fuzz_color" />
</dot>
<power name="sheenRoughness" type="float">
<input name="in1" type="float" interfacename="fuzz_roughness" />
<input name="in2" type="float" value="2.5" />
</power>

<!--Coat-->
<dot name="coat" type="float">
<input name="in" type="float" interfacename="coat_weight" />
</dot>
<dot name="coatColor" type="color3">
<input name="in" type="color3" interfacename="coat_color" />
</dot>
<dot name="coatRoughness" type="float">
<input name="in" type="float" interfacename="coat_roughness" />
</dot>
<dot name="coatAnisotropy" type="float">
<input name="in" type="float" interfacename="coat_roughness_anisotropy" />
</dot>
<dot name="coatIOR" type="float">
<input name="in" type="float" interfacename="coat_ior" />
</dot>
<dot name="coatAffectColor" type="float">
<input name="in" type="float" interfacename="coat_darkening" />
</dot>
<constant name="coatAffectRoughness" type="float">
<input name="value" type="float" value="1.0" />
</constant>

<!--ThinFilm-->
<multiply name="thinFilmThicknessConversion" type="float">
<input name="in1" type="float" interfacename="thin_film_thickness" />
<input name="in2" type="float" value="1000" />
</multiply>
<ifgreater name="thinFilmThickness" type="float">
<input name="value1" type="float" interfacename="thin_film_weight" />
<input name="value2" type="float" value="0.0" />
<input name="in1" type="float" nodename="thinFilmThicknessConversion" />
<input name="in2" type="float" value="0.0" />
</ifgreater>
<dot name="thinFilmIOR" type="float">
<input name="in" type="float" interfacename="thin_film_ior" />
</dot>

<!--Emission-->
<dot name="emission" type="float">
<input name="in" type="float" interfacename="emission_luminance" />
</dot>
<dot name="emissionColor" type="color3">
<input name="in" type="color3" interfacename="emission_color" />
</dot>

<!--Geometry-->
<convert name="geometryOpacity" type="color3">
<input name="in" type="float" interfacename="geometry_opacity" />
</convert>
<dot name="geometryThinWalled" type="boolean">
<input name="in" type="boolean" interfacename="geometry_thin_walled" />
</dot>

<!--Outputs-->
<output name="base_out" type="float" nodename="base" />
<output name="base_color_out" type="color3" nodename="baseColor" />
<output name="diffuse_roughness_out" type="float" nodename="diffuseRoughness" />
<output name="metalness_out" type="float" nodename="metalness" />

<output name="specular_out" type="float" nodename="spec" />
<output name="specular_color_out" type="color3" nodename="specColor" />
<output name="specular_roughness_out" type="float" nodename="specRoughness" />
<output name="specular_IOR_out" type="float" nodename="specIOR" />
<output name="specular_anisotropy_out" type="float" nodename="specAnisotropy" />

<output name="transmission_out" type="float" nodename="transmission" />
<output name="transmission_color_out" type="color3" nodename="transmissionColor" />
<output name="transmission_depth_out" type="float" nodename="transmissionDepth" />
<output name="transmission_scatter_out" type="color3" nodename="transmissionScatter" />
<output name="transmission_scatter_anisotropy_out" type="float" nodename="transmissionScatterAnisotropy" />
<output name="transmission_dispersion_out" type="float" nodename="transmissionDispersion" />

<output name="subsurface_out" type="float" nodename="subsurface" />
<output name="subsurface_color_out" type="color3" nodename="subsurfaceColor" />
<output name="subsurface_radius_out" type="color3" nodename="subsurfaceRadius" />
<output name="subsurface_scale_out" type="float" nodename="subsurfaceScale" />
<output name="subsurface_anisotropy_out" type="float" nodename="subsurfaceAnisotropy" />

<output name="sheen_out" type="float" nodename="sheen" />
<output name="sheen_color_out" type="color3" nodename="sheenColor" />
<output name="sheen_roughness_out" type="float" nodename="sheenRoughness" />

<output name="coat_out" type="float" nodename="coat" />
<output name="coat_color_out" type="color3" nodename="coatColor" />
<output name="coat_roughness_out" type="float" nodename="coatRoughness" />
<output name="coat_anisotropy_out" type="float" nodename="coatAnisotropy" />
<output name="coat_IOR_out" type="float" nodename="coatIOR" />
<output name="coat_affect_color_out" type="float" nodename="coatAffectColor" />
<output name="coat_affect_roughness_out" type="float" nodename="coatAffectRoughness" />

<output name="thin_film_thickness_out" type="float" nodename="thinFilmThickness" />
<output name="thin_film_IOR_out" type="float" nodename="thinFilmIOR" />

<output name="emission_out" type="float" nodename="emission" />
<output name="emission_color_out" type="color3" nodename="emissionColor" />

<output name="opacity_out" type="color3" nodename="geometryOpacity" />
<output name="thin_walled_out" type="boolean" nodename="geometryThinWalled" />
</nodegraph>
</materialx>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<materialx version="1.39" colorspace="lin_rec709">
<surfacematerial name="geom_hint" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="geometric_opacity_hint" />
</surfacematerial>
<open_pbr_surface name="geometric_opacity_hint" type="surfaceshader">
<input name="geometry_opacity" type="float" value="0.5" />
</open_pbr_surface>
<surfacematerial name="transp_hint" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="transparency_weight_hint" />
</surfacematerial>
<open_pbr_surface name="transparency_weight_hint" type="surfaceshader">
<input name="transmission_weight" type="float" value="0.8" />
</open_pbr_surface>
</materialx>
13 changes: 13 additions & 0 deletions source/MaterialXCore/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ InterfaceElementPtr NodeDef::getImplementation(const string& target) const
return InterfaceElementPtr();
}

const StringMap NodeDef::getInputHints() const
{
StringMap hints;
for (InputPtr input : getActiveInputs())
{
if (input->hasHint())
{
hints[input->getName()] = input->getHint();
}
}
return hints;
}

bool NodeDef::validate(string* message) const
{
bool res = true;
Expand Down
7 changes: 7 additions & 0 deletions source/MaterialXCore/Definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ class MX_CORE_API NodeDef : public InterfaceElement
/// an Implementation element or a NodeGraph element.
InterfaceElementPtr getImplementation(const string& target = EMPTY_STRING) const;

/// @}
/// @name Hints
/// @{

/// Return list of input hint pairs of the form { input_name, hint_string }
const StringMap getInputHints() const;

/// @}
/// @name Validation
/// @{
Expand Down
4 changes: 4 additions & 0 deletions source/MaterialXCore/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const string InterfaceElement::TARGET_ATTRIBUTE = "target";
const string InterfaceElement::VERSION_ATTRIBUTE = "version";
const string InterfaceElement::DEFAULT_VERSION_ATTRIBUTE = "isdefaultversion";
const string Input::DEFAULT_GEOM_PROP_ATTRIBUTE = "defaultgeomprop";
const string Input::HINT_ATTRIBUTE = "hint";
const string Input::TRANSPARENCY_HINT = "transparency";
const string Input::OPACITY_HINT = "opacity";
const string Input::ANISOTROPY_HINT = "anisotropy";
const string Output::DEFAULT_INPUT_ATTRIBUTE = "defaultinput";

//
Expand Down
Loading

0 comments on commit 99452f6

Please sign in to comment.