Skip to content

Commit

Permalink
Add triangle wave node (AcademySoftwareFoundation#1334)
Browse files Browse the repository at this point in the history
This node generates values from zero to one based on the input value.
  • Loading branch information
Cinifreak authored Jul 12, 2023
1 parent 71c513b commit 595a500
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libraries/stdlib/stdlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,16 @@
<output name="out" type="stringarray" defaultinput="in1" />
</nodedef>

<!--
Node: <trianglewave>
Generate a triangle wave from the given scalar input.
The generated wave ranges from zero to one and repeats on integer boundaries.
-->
<nodedef name="ND_trianglewave_float" node="trianglewave" nodegroup="math">
<input name="in" type="float" value="0" />
<output name="out" type="float" />
</nodedef>

<!-- ======================================================================== -->
<!-- Adjustment nodes -->
<!-- ======================================================================== -->
Expand Down
26 changes: 26 additions & 0 deletions libraries/stdlib/stdlib_ng.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,32 @@
</magnitude>
<output name="out" type="float" nodename="N_mtlxmagnitude" />
</nodegraph>

<!--
Node: <trianglewave>
Generate a triangle wave from the given scalar input.
The generated wave ranges from zero to one and repeats on integer boundaries.
-->
<nodegraph name="NG_trianglewave_float" nodedef="ND_trianglewave_float">
<absval name="absval1" type="float">
<input name="in" type="float" interfacename="in" />
</absval>
<modulo name="modulo1" type="float">
<input name="in1" type="float" nodename="absval1" />
</modulo>
<subtract name="subtract1" type="float">
<input name="in1" type="float" nodename="modulo1" />
<input name="in2" type="float" value="0.5" />
</subtract>
<absval name="absval2" type="float">
<input name="in" type="float" nodename="subtract1" />
</absval>
<subtract name="subtract2" type="float">
<input name="in1" type="float" value="0.5" />
<input name="in2" type="float" nodename="absval2" />
</subtract>
<output name="out" type="float" nodename="subtract2" />
</nodegraph>

<!-- ======================================================================== -->
<!-- Adjustment nodes -->
Expand Down

0 comments on commit 595a500

Please sign in to comment.