Skip to content

Commit

Permalink
Merge pull request #651 from williamchange/variadic-transform-sdf
Browse files Browse the repository at this point in the history
Variadic 2D/3D SDF transform nodes
  • Loading branch information
RodZill4 authored Apr 30, 2024
2 parents 4d956c2 + 9d7c5f9 commit 08d5c77
Show file tree
Hide file tree
Showing 24 changed files with 77 additions and 69 deletions.
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/sdf3d_rotate.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "sdf3d_rotate",
"node_position": {
"x": 0,
Expand Down Expand Up @@ -41,8 +42,8 @@
"default": "vec2(100.0, 0.0)",
"label": "",
"longdesc": "The input object as signed distance function",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf3dc"
}
],
Expand All @@ -52,8 +53,8 @@
"outputs": [
{
"longdesc": "The rotated object",
"sdf3dc": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))",
"shortdesc": "Output",
"sdf3dc": "$in#(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))",
"shortdesc": "Output#",
"type": "sdf3dc"
}
],
Expand Down
11 changes: 6 additions & 5 deletions addons/material_maker/nodes/sdf3d_scale.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "sdf3d_scale",
"node_position": {
"x": 0,
Expand All @@ -9,15 +10,15 @@
},
"seed_int": 0,
"shader_model": {
"code": "vec2 $(name_uv)_in = $in(($uv)/$s);",
"code": "",
"global": "",
"inputs": [
{
"default": "vec2(100.0, 0.0)",
"label": "",
"longdesc": "The input object as a signed distance function",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf3dc"
}
],
Expand All @@ -27,8 +28,8 @@
"outputs": [
{
"longdesc": "The scaled object",
"sdf3dc": "vec2($(name_uv)_in.x*$s, $(name_uv)_in.y)",
"shortdesc": "Output",
"sdf3dc": "vec2($in#(($uv)/$s).x*$s, $in#(($uv)/$s).y)",
"shortdesc": "Output#",
"type": "sdf3dc"
}
],
Expand Down
11 changes: 6 additions & 5 deletions addons/material_maker/nodes/sdf3d_scale_xyz.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "sdf3d_scale_xyz",
"node_position": {
"x": 0,
Expand All @@ -12,15 +13,15 @@
},
"seed_int": 0,
"shader_model": {
"code": "vec2 $(name_uv)_in = $in(($uv)/vec3($sx*$s,$sy*$s,$sz*$s));",
"code": "",
"global": "",
"inputs": [
{
"default": "vec2(100.0, 0.0)",
"label": "",
"longdesc": "The input object as a signed distance function",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf3dc"
}
],
Expand All @@ -30,8 +31,8 @@
"outputs": [
{
"longdesc": "The scaled object",
"sdf3dc": "vec2($(name_uv)_in.x*min(min($sx*$s,$sy*$s),$sz*$s), $(name_uv)_in.y)",
"shortdesc": "Output",
"sdf3dc": "vec2($in#(($uv)/vec3($sx*$s,$sy*$s,$sz*$s)).x*min(min($sx*$s,$sy*$s),$sz*$s), $in#(($uv)/vec3($sx*$s,$sy*$s,$sz*$s)).y)",
"shortdesc": "Output#",
"type": "sdf3dc"
}
],
Expand Down
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/sdf3d_translate.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "sdf3d_translate",
"node_position": {
"x": 0,
Expand All @@ -18,8 +19,8 @@
"default": "vec2(100.0, 0.0)",
"label": "",
"longdesc": "The input object as a signed distance function",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf3dc"
}
],
Expand All @@ -29,8 +30,8 @@
"outputs": [
{
"longdesc": "The translated object",
"sdf3dc": "$in($uv-vec3($x, $y, $z))",
"shortdesc": "Output",
"sdf3dc": "$in#($uv-vec3($x, $y, $z))",
"shortdesc": "Output#",
"type": "sdf3dc"
}
],
Expand Down
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/sdrotate.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "sdrotate",
"node_position": {
"x": 0,
Expand Down Expand Up @@ -27,8 +28,8 @@
"default": "0.0",
"label": "",
"longdesc": "The input shape, defined as a signed distance function",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf2d"
}
],
Expand All @@ -38,8 +39,8 @@
"outputs": [
{
"longdesc": "The rotated shape",
"sdf2d": "$in(sdf2d_rotate($uv, $a*0.01745329251))",
"shortdesc": "Output",
"sdf2d": "$in#(sdf2d_rotate($uv, $a*0.01745329251))",
"shortdesc": "Output#",
"type": "sdf2d"
}
],
Expand Down
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/sdscale.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "sdscale",
"node_position": {
"x": 0,
Expand All @@ -16,8 +17,8 @@
"default": "0.0",
"label": "",
"longdesc": "The input shape, defined as a signed distance function",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf2d"
}
],
Expand All @@ -27,8 +28,8 @@
"outputs": [
{
"longdesc": "The generated scaled shape",
"sdf2d": "$in(($uv-vec2(0.5))/$s+vec2(0.5))*$s",
"shortdesc": "Output",
"sdf2d": "$in#(($uv-vec2(0.5))/$s+vec2(0.5))*$s",
"shortdesc": "Output#",
"type": "sdf2d"
}
],
Expand Down
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/sdscalexy.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "sdscalexy",
"node_position": {
"x": 0,
Expand All @@ -18,8 +19,8 @@
"default": "0.0",
"label": "",
"longdesc": "The input shape, defined as a signed distance function",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf2d"
}
],
Expand All @@ -29,8 +30,8 @@
"outputs": [
{
"longdesc": "The generated scaled shape",
"sdf2d": "$in(vec2(($uv.x-0.5)/($sx*$s),($uv.y-0.5)/($sy*$s))+vec2(0.5))*min(abs($sx*$s),abs($sy*$s))",
"shortdesc": "Output",
"sdf2d": "$in#(vec2(($uv.x-0.5)/($sx*$s),($uv.y-0.5)/($sy*$s))+vec2(0.5))*min(abs($sx*$s),abs($sy*$s))",
"shortdesc": "Output#",
"type": "sdf2d"
}
],
Expand Down
9 changes: 5 additions & 4 deletions addons/material_maker/nodes/sdtranslate.mmg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"generic_size": 1,
"name": "sdtranslate",
"node_position": {
"x": 0,
Expand All @@ -17,8 +18,8 @@
"default": "0.0",
"label": "",
"longdesc": "The input shape, defined as a signed distance function",
"name": "in",
"shortdesc": "Input",
"name": "in#",
"shortdesc": "Input#",
"type": "sdf2d"
}
],
Expand All @@ -28,8 +29,8 @@
"outputs": [
{
"longdesc": "The translated shape",
"sdf2d": "$in($uv-vec2($x, $y))",
"shortdesc": "Output",
"sdf2d": "$in#($uv-vec2($x, $y))",
"shortdesc": "Output#",
"type": "sdf2d"
}
],
Expand Down
Binary file modified material_maker/doc/images/node_3d_sdf_transforms_rotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified material_maker/doc/images/node_3d_sdf_transforms_scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified material_maker/doc/images/node_3d_sdf_transforms_scale_xyz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified material_maker/doc/images/node_3d_sdf_transforms_translate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified material_maker/doc/images/node_simple_sdf_transforms_rotate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified material_maker/doc/images/node_simple_sdf_transforms_scale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified material_maker/doc/images/node_simple_sdf_transforms_scale_xy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified material_maker/doc/images/node_simple_sdf_transforms_translate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions material_maker/doc/node_3d_sdf_transforms_rotate.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
Rotate node
...........

The **Rotate** node generates a 3D signed distance function of a rotated scene
based on its input. If the input shapes are associated to color indexes, the
rotate node applies them to the output.
The **Rotate** node is variadic and generates 3D signed distance functions of rotated scenes
based on its inputs. If the input shapes are associated to color indexes, the
rotate node applies them to the outputs.

.. image:: images/node_3d_sdf_transforms_rotate.png
:align: center

Inputs
::::::

The **Rotate** node accepts an input in 3D signed distance function format.
The **Rotate** node accepts one or more inputs in 3D signed distance function format.

Outputs
:::::::

The **Rotate** node generates a signed distance function of the
rotated input shape.
The **Rotate** node generates signed distance functions of the
rotated input shapes.

Parameters
::::::::::
Expand Down
10 changes: 5 additions & 5 deletions material_maker/doc/node_3d_sdf_transforms_scale.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Scale node
..........

The **Scale** node generates a 3D signed distance function of a scaled shape
based on its input. If the input shapes are associated to color indexes, the
The **Scale** node is variadic and generates 3D signed distance functions of scaled shapes
based on its inputs. If the input shapes are associated to color indexes, the
scale node applies them to the output.

.. image:: images/node_3d_sdf_transforms_scale.png
Expand All @@ -11,13 +11,13 @@ scale node applies them to the output.
Inputs
::::::

The **Scale** node accepts an input in 3D signed distance function format.
The **Scale** node accepts one or more inputs in 3D signed distance function format.

Outputs
:::::::

The **Scale** node generates a signed distance function of the
scaled input shape.
The **Scale** node generates signed distance functions of the
scaled input shapes.

Parameters
::::::::::
Expand Down
6 changes: 3 additions & 3 deletions material_maker/doc/node_3d_sdf_transforms_scale_xyz.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Scale XYZ node
..............

The **Scale XYZ** node generates a 3D signed distance function of a scaled shape
based on its input in a non uniform way.
The result shape is no longer a correct signed distance function, but can be used for many operations like ray marching.
The **Scale XYZ** node is variadic and generates 3D signed distance functions of scaled shapes
based on its inputs in a non uniform way.
The result shapes are no longer correct signed distance functions, but can be used for many operations like ray marching.

.. image:: images/node_3d_sdf_transforms_scale_xyz.png
:align: center
Expand Down
10 changes: 5 additions & 5 deletions material_maker/doc/node_3d_sdf_transforms_translate.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Translate node
..............

The **Translate** node generates a 3D signed distance function of a translated shape
based on its input. If the input shapes are associated to color indexes, the
The **Translate** node is variadic and generates 3D signed distance functiosn of translated shapes
based on its inputs. If the input shapes are associated to color indexes, the
translate node applies them to the output.

.. image:: images/node_3d_sdf_transforms_translate.png
Expand All @@ -11,13 +11,13 @@ translate node applies them to the output.
Inputs
::::::

The **Translate** node accepts an input in 3D signed distance function format.
The **Translate** node accepts one or more inputs in 3D signed distance function format.

Outputs
:::::::

The **Translate** node generates a signed distance function of the
translated input shape.
The **Translate** node generates signed distance functions of the
translated input shapes.

Parameters
::::::::::
Expand Down
8 changes: 4 additions & 4 deletions material_maker/doc/node_simple_sdf_transforms_rotate.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Rotate node
.............

The **Rotate** node generates a signed distance image obtained by rotating its input.
The **Rotate** node is variadic and generates signed distance images obtained by rotating its inputs.

.. image:: images/node_simple_sdf_transforms_rotate.png
:align: center

Inputs
::::::

The **Rotate** node accepts a single input in signed distance function format.
The **Rotate** node accepts one or more inputs in signed distance function format.

Outputs
:::::::

The **Rotate** node generates a signed distance function of the
rotated shape.
The **Rotate** node generates a signed distance functions of the
rotated shapes.

Parameters
::::::::::
Expand Down
8 changes: 4 additions & 4 deletions material_maker/doc/node_simple_sdf_transforms_scale.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Scale node
.............

The **Scale** node generates a signed distance image obtained by scaling its input.
The **Scale** node is variadic and generates signed distance images obtained by scaling its inputs.

.. image:: images/node_simple_sdf_transforms_scale.png
:align: center

Inputs
::::::

The **Scale** node accepts a single input in signed distance function format.
The **Scale** node accepts one or more inputs in signed distance function format.

Outputs
:::::::

The **Scale** node generates a signed distance function of the
scaled shape.
The **Scale** node generates signed distance functions of the
scaled shapes.

Parameters
::::::::::
Expand Down
Loading

0 comments on commit 08d5c77

Please sign in to comment.