Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for geompropvalueuniform node #2092

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 0 additions & 6 deletions documents/Specification/MaterialX.Proposals.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,6 @@ We have a standard 3d fractal noise, but a 2d variant would be useful as well.

* **`bump`**: Existing node, proposal to add a vector3 `bitangent` input

<a id="node-geompropvalueuniform"> </a>

* **`geompropvalueuniform`**: the value of the specified uniform geometric property (defined using &lt;geompropdef>) of the currently-bound geometry. This node's type must match that of the referenced geomprop.
* `geomprop` (uniform string): the geometric property to be referenced.
* `default` (same type as the geomprop's value): a value to return if the specified `geomprop` is not defined on the current geometry.

Note: when &lt;geompropvalueuniform> is added, the text in the first paragraph of the Specification about Node Inputs should be revised to include "&lt;geompropvalueuniform>" as an example of "or any other node whose output is explicitly declared to be uniform".


Expand Down
6 changes: 6 additions & 0 deletions documents/Specification/MaterialX.Specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,12 @@ Standard Geometric nodes:
* `geomprop` (uniform string): the geometric property to be referenced.
* `default` (same type as the geomprop's value): a value to return if the specified `geomprop` is not defined on the current geometry.

<a id="node-geompropvalueuniform"> </a>

* **`geompropvalueuniform`**: the value of the specified uniform geometric property (defined using &lt;geompropdef>) of the currently-bound geometry. This node's type must match that of the referenced geomprop.
* `geomprop` (uniform string): the geometric property to be referenced.
* `default` (same type as the geomprop's value): a value to return if the specified `geomprop` is not defined on the current geometry.

Additionally, the `geomcolor` and `geompropvalue` nodes for color3/color4-type properties can take a `colorspace` attribute to declare what colorspace the color property value is in; the default is "none" for no colorspace declaration (and hence no colorspace conversion).


Expand Down
18 changes: 15 additions & 3 deletions libraries/bxdf/usd_preview_surface.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@
</nodedef>
<nodedef name="ND_UsdPrimvarReader_string" nodegroup="geometric" node="UsdPrimvarReader">
<input name="varname" type="string" value="" uniform="true" />
<input name="fallback" type="string" value="" />
<output name="out" type="string" />
<input name="fallback" type="string" value="" uniform="true" />
<output name="out" type="string" uniform="true"/>
</nodedef>
<nodedef name="ND_UsdPrimvarReader_filename" nodegroup="geometric" node="UsdPrimvarReader">
<input name="varname" type="string" value="" uniform="true" />
<input name="fallback" type="filename" value="" uniform="true" />
<output name="out" type="filename" uniform="true"/>
</nodedef>
<nodedef name="ND_UsdPrimvarReader_float" nodegroup="geometric" node="UsdPrimvarReader">
<input name="varname" type="string" value="" uniform="true" />
Expand Down Expand Up @@ -363,7 +368,14 @@
<input name="geomprop" type="string" interfacename="varname" />
<input name="default" type="string" interfacename="fallback" />
</geompropvalue>
<output name="out" type="string" nodename="primvar" />
<output name="out" type="string" nodename="primvar" uniform="true" />
</nodegraph>
<nodegraph name="IMP_UsdPrimvarReader_filename" nodedef="ND_UsdPrimvarReader_filename">
<geompropvalue name="primvar" type="string">
crydalch marked this conversation as resolved.
Show resolved Hide resolved
<input name="geomprop" type="string" interfacename="varname" />
<input name="default" type="filename" interfacename="fallback" />
</geompropvalue>
<output name="out" type="filename" nodename="primvar" uniform="true" />
</nodegraph>
<nodegraph name="IMP_UsdPrimvarReader_float" nodedef="ND_UsdPrimvarReader_float">
<geompropvalue name="primvar" type="float">
Expand Down
5 changes: 4 additions & 1 deletion libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,17 @@
<!-- <geompropvalue> -->
<implementation name="IM_geompropvalue_integer_genglsl" nodedef="ND_geompropvalue_integer" function="mx_geompropvalue_int" target="genglsl" />
<implementation name="IM_geompropvalue_boolean_genglsl" nodedef="ND_geompropvalue_boolean" function="mx_geompropvalue_bool" target="genglsl" />
<implementation name="IM_geompropvalue_string_genglsl" nodedef="ND_geompropvalue_string" function="mx_geompropvalue_string" target="genglsl" />
<implementation name="IM_geompropvalue_float_genglsl" nodedef="ND_geompropvalue_float" function="mx_geompropvalue_float" target="genglsl" />
<implementation name="IM_geompropvalue_color3_genglsl" nodedef="ND_geompropvalue_color3" function="mx_geompropvalue_color" target="genglsl" />
<implementation name="IM_geompropvalue_color4_genglsl" nodedef="ND_geompropvalue_color4" function="mx_geompropvalue_color4" target="genglsl" />
<implementation name="IM_geompropvalue_vector2_genglsl" nodedef="ND_geompropvalue_vector2" function="mx_geompropvalue_vector2" target="genglsl" />
<implementation name="IM_geompropvalue_vector3_genglsl" nodedef="ND_geompropvalue_vector3" function="mx_geompropvalue_vector" target="genglsl" />
<implementation name="IM_geompropvalue_vector4_genglsl" nodedef="ND_geompropvalue_vector4" function="mx_geompropvalue_vector4" target="genglsl" />

<!-- <geompropvalueuniform> -->
<implementation name="IM_geompropvalue_string_genglsl" nodedef="ND_geompropvalueuniform_string" function="mx_geompropvalue_string" target="genglsl" />
<implementation name="IM_geompropvalue_filename_genglsl" nodedef="ND_geompropvalueuniform_filename" function="mx_geompropvalue_string" target="genglsl" />

<!-- ======================================================================== -->
<!-- Application nodes -->
<!-- ======================================================================== -->
Expand Down
5 changes: 4 additions & 1 deletion libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@
<!-- <geompropvalue> -->
<implementation name="IM_geompropvalue_integer_genmdl" nodedef="ND_geompropvalue_integer" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_integer(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalue_boolean_genmdl" nodedef="ND_geompropvalue_boolean" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_boolean(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalue_string_genmdl" nodedef="ND_geompropvalue_string" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_string(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalue_float_genmdl" nodedef="ND_geompropvalue_float" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_float(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalue_color3_genmdl" nodedef="ND_geompropvalue_color3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_color3(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalue_color4_genmdl" nodedef="ND_geompropvalue_color4" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_color4(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalue_vector2_genmdl" nodedef="ND_geompropvalue_vector2" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_vector2(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalue_vector3_genmdl" nodedef="ND_geompropvalue_vector3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_vector3(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalue_vector4_genmdl" nodedef="ND_geompropvalue_vector4" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_vector4(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />

<!-- <geompropvalueuniform> -->
<implementation name="IM_geompropvalueuniform_string_genmdl" nodedef="ND_geompropvalueuniform_string" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_string(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />
<implementation name="IM_geompropvalueuniform_filename_genmdl" nodedef="ND_geompropvalueuniform_filename" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_geompropvalue_string(mxp_geomprop:{{geomprop}}, mxp_default:{{default}})" target="genmdl" />

<!-- ======================================================================== -->
<!-- Application nodes -->
<!-- ======================================================================== -->
Expand Down
5 changes: 4 additions & 1 deletion libraries/stdlib/genmsl/stdlib_genmsl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@
<!-- <geompropvalue> -->
<implementation name="IM_geompropvalue_integer_genmsl" nodedef="ND_geompropvalue_integer" function="mx_geompropvalue_int" target="genmsl" />
<implementation name="IM_geompropvalue_boolean_genmsl" nodedef="ND_geompropvalue_boolean" function="mx_geompropvalue_bool" target="genmsl" />
<implementation name="IM_geompropvalue_string_genmsl" nodedef="ND_geompropvalue_string" function="mx_geompropvalue_string" target="genmsl" />
<implementation name="IM_geompropvalue_float_genmsl" nodedef="ND_geompropvalue_float" function="mx_geompropvalue_float" target="genmsl" />
<implementation name="IM_geompropvalue_color3_genmsl" nodedef="ND_geompropvalue_color3" function="mx_geompropvalue_color" target="genmsl" />
<implementation name="IM_geompropvalue_color4_genmsl" nodedef="ND_geompropvalue_color4" function="mx_geompropvalue_color4" target="genmsl" />
<implementation name="IM_geompropvalue_vector2_genmsl" nodedef="ND_geompropvalue_vector2" function="mx_geompropvalue_vector2" target="genmsl" />
<implementation name="IM_geompropvalue_vector3_genmsl" nodedef="ND_geompropvalue_vector3" function="mx_geompropvalue_vector" target="genmsl" />
<implementation name="IM_geompropvalue_vector4_genmsl" nodedef="ND_geompropvalue_vector4" function="mx_geompropvalue_vector4" target="genmsl" />

<!-- <geompropvalueuniform> -->
<implementation name="IM_geompropvalue_string_genmsl" nodedef="ND_geompropvalueuniform_string" function="mx_geompropvalueuniform_string" target="genmsl" />
crydalch marked this conversation as resolved.
Show resolved Hide resolved
<implementation name="IM_geompropvalue_filename_genmsl" nodedef="ND_geompropvalueuniform_filename" function="mx_geompropvalue_string" target="genmsl" />

<!-- ======================================================================== -->
<!-- Application nodes -->
<!-- ======================================================================== -->
Expand Down
5 changes: 5 additions & 0 deletions libraries/stdlib/genosl/mx_geompropvalueuniform_filename.osl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void mx_geompropvalueuniform_filename(string geomprop, string defaultVal, output string out)
{
if (getattribute(geomprop, out) == 0)
out = defaultVal;
}
5 changes: 5 additions & 0 deletions libraries/stdlib/genosl/mx_geompropvalueuniform_string.osl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
void mx_geompropvalueuniform_string(string geomprop, string defaultVal, output string out)
{
if (getattribute(geomprop, out) == 0)
out = defaultVal;
}
5 changes: 4 additions & 1 deletion libraries/stdlib/genosl/stdlib_genosl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,17 @@
<!-- <geompropvalue> -->
<implementation name="IM_geompropvalue_integer_genosl" nodedef="ND_geompropvalue_integer" file="mx_geompropvalue_integer.osl" function="mx_geompropvalue_integer" target="genosl" />
<implementation name="IM_geompropvalue_boolean_genosl" nodedef="ND_geompropvalue_boolean" file="mx_geompropvalue_boolean.osl" function="mx_geompropvalue_boolean" target="genosl" />
<implementation name="IM_geompropvalue_string_genosl" nodedef="ND_geompropvalue_string" file="mx_geompropvalue_string.osl" function="mx_geompropvalue_string" target="genosl" />
<implementation name="IM_geompropvalue_float_genosl" nodedef="ND_geompropvalue_float" file="mx_geompropvalue_float.osl" function="mx_geompropvalue_float" target="genosl" />
<implementation name="IM_geompropvalue_color3_genosl" nodedef="ND_geompropvalue_color3" file="mx_geompropvalue_color3.osl" function="mx_geompropvalue_color" target="genosl" />
<implementation name="IM_geompropvalue_color4_genosl" nodedef="ND_geompropvalue_color4" file="mx_geompropvalue_color4.osl" function="mx_geompropvalue_color4" target="genosl" />
<implementation name="IM_geompropvalue_vector2_genosl" nodedef="ND_geompropvalue_vector2" file="mx_geompropvalue_vector2.osl" function="mx_geompropvalue_vector2" target="genosl" />
<implementation name="IM_geompropvalue_vector3_genosl" nodedef="ND_geompropvalue_vector3" file="mx_geompropvalue_vector3.osl" function="mx_geompropvalue_vector" target="genosl" />
<implementation name="IM_geompropvalue_vector4_genosl" nodedef="ND_geompropvalue_vector4" file="mx_geompropvalue_vector4.osl" function="mx_geompropvalue_vector4" target="genosl" />

<!-- <geompropvalueuniform> -->
<implementation name="IM_geompropvalueuniform_string_genosl" nodedef="ND_geompropvalueuniform_string" file="mx_geompropvalueuniform_string.osl" function="mx_geompropvalueuniform_string" target="genosl" />
<implementation name="IM_geompropvalueuniform_filename_genosl" nodedef="ND_geompropvalueuniform_filename" file="mx_geompropvalueuniform_filename.osl" function="mx_geompropvalueuniform_filename" target="genosl" />

<!-- ======================================================================== -->
<!-- Application nodes -->
<!-- ======================================================================== -->
Expand Down
21 changes: 16 additions & 5 deletions libraries/stdlib/stdlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -1306,11 +1306,6 @@
<input name="default" type="boolean" value="false" />
<output name="out" type="boolean" default="false" />
</nodedef>
<nodedef name="ND_geompropvalue_string" node="geompropvalue" nodegroup="geometric">
<input name="geomprop" type="string" value="" uniform="true" />
<input name="default" type="string" value="" uniform="true" />
<output name="out" type="string" default="" />
</nodedef>
<nodedef name="ND_geompropvalue_float" node="geompropvalue" nodegroup="geometric">
<input name="geomprop" type="string" value="" uniform="true" />
<input name="default" type="float" value="0.0" />
Expand Down Expand Up @@ -1342,6 +1337,22 @@
<output name="out" type="vector4" default="0.0, 0.0, 0.0, 0.0" />
</nodedef>

<!--
Node: <geompropvalueuniform>
The uniform, non-varying value of the specified geometric property for the current geometry.
-->
<nodedef name="ND_geompropvalueuniform_string" node="geompropvalueuniform" nodegroup="geometric">
<input name="geomprop" type="string" value="" uniform="true" />
<input name="default" type="string" value="" uniform="true" />
<output name="out" type="string" default="" uniform="true" />
</nodedef>
<nodedef name="ND_geompropvalueuniform_filename" node="geompropvalueuniform" nodegroup="geometric">
<input name="geomprop" type="filename" value="" uniform="true" />
<input name="default" type="filename" value="" uniform="true" />
<output name="out" type="filename" default="" uniform="true" />
</nodedef>


<!--
Node: <bump>
Offset the surface normal by a scalar value.
Expand Down