Skip to content

Commit

Permalink
Add a 2d checkerboard pattern node (AcademySoftwareFoundation#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
crydalch authored May 18, 2023
1 parent b35699c commit 301f2c9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libraries/stdlib/stdlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,19 @@
<output name="out" type="float" />
</nodedef>

<!--
Node: <checkerboard>
A 2D checkerboard pattern.
-->
<nodedef name="ND_checkerboard_color3" node="checkerboard" nodegroup="procedural2d">
<input name="color1" type="color3" uiname="Color 1" value="1.0, 1.0, 1.0" doc="The first color used in the checkerboard pattern." />
<input name="color2" type="color3" uiname="Color 2" value="0.0, 0.0, 0.0" doc="The second color used in the checkerboard pattern." />
<input name="freq" type="vector2" uiname="Frequency" value="8, 8" doc="The frequency of checkers, with higher values producing smaller squares. Default is (8, 8)." />
<input name="offset" type="vector2" uiname="Offset" value="0, 0" doc="Shift the pattern in 2d space. Default is (0, 0)." />
<input name="texcoord" type="vector2" uiname="Texture Coordinates" defaultgeomprop="UV0" doc="The input 2d space. Default is the first texture coordinates." />
<output name="out" type="color3" />
</nodedef>

<!-- ======================================================================== -->
<!-- Geometric nodes -->
<!-- ======================================================================== -->
Expand Down
48 changes: 48 additions & 0 deletions libraries/stdlib/stdlib_ng.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,54 @@
<output name="out" type="float" nodename="N_range" />
</nodegraph>

<!--
<checkerboard>
A 2D checkerboard pattern.
-->
<nodegraph name="NG_checkerboard_color3" nodedef="ND_checkerboard_color3">
<separate2 name="N_mtlxseparate2" type="multioutput">
<input name="in" type="vector2" nodename="N_mtlxplace2d1" />
</separate2>
<modulo name="N_mtlxmodulo1" type="float">
<input name="in1" type="float" nodename="N_mtlxseparate2" output="outx" />
<input name="in2" type="float" value="2" />
</modulo>
<multiply name="N_mult" type="vector2">
<input name="in1" type="vector2" interfacename="texcoord" />
<input name="in2" type="vector2" interfacename="freq" />
</multiply>
<modulo name="N_mtlxmodulo2" type="float">
<input name="in1" type="float" nodename="N_mtlxseparate2" output="outy" />
<input name="in2" type="float" value="2" />
</modulo>
<floor name="N_mtlxfloor2" type="float">
<input name="in" type="float" nodename="N_mtlxmodulo1" />
</floor>
<floor name="N_mtlxfloor3" type="float">
<input name="in" type="float" nodename="N_mtlxmodulo2" />
</floor>
<add name="N_mtlxadd2" type="float">
<input name="in1" type="float" nodename="N_mtlxfloor2" />
<input name="in2" type="float" nodename="N_mtlxfloor3" />
</add>
<ifequal name="N_mtlxifequal2" type="float">
<input name="value1" type="float" nodename="N_mtlxadd2" />
<input name="value2" type="float" value="1" />
<input name="in1" type="float" value="1" />
<input name="in2" type="float" value="0" />
</ifequal>
<place2d name="N_mtlxplace2d1" type="vector2">
<input name="texcoord" type="vector2" nodename="N_mult" />
<input name="offset" type="vector2" interfacename="offset" />
</place2d>
<mix name="N_mix_color3" type="color3">
<input name="bg" type="color3" interfacename="color2" />
<input name="fg" type="color3" interfacename="color1" />
<input name="mix" type="float" nodename="N_mtlxifequal2" />
</mix>
<output name="out" type="color3" nodename="N_mix_color3" />
</nodegraph>

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

0 comments on commit 301f2c9

Please sign in to comment.