Skip to content

Commit

Permalink
Initial work on geompropvalueuniform
Browse files Browse the repository at this point in the history
  • Loading branch information
crydalch committed Oct 29, 2024
1 parent 7af264b commit e229cf1
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 12 deletions.
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">
<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" />
<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

0 comments on commit e229cf1

Please sign in to comment.