diff --git a/addons/material_maker/doc/base_library.rst b/addons/material_maker/doc/base_library.rst index 7d2b956..fb8309e 100644 --- a/addons/material_maker/doc/base_library.rst +++ b/addons/material_maker/doc/base_library.rst @@ -8,6 +8,7 @@ to describe procedural materials. :maxdepth: 2 nodes_simple + nodes_3d nodes_pattern nodes_noise nodes_filter diff --git a/addons/material_maker/doc/images/node_sdf3d_boolean.png b/addons/material_maker/doc/images/node_sdf3d_boolean.png new file mode 100644 index 0000000..5b8462e Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_boolean.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_boolean_sample.png b/addons/material_maker/doc/images/node_sdf3d_boolean_sample.png new file mode 100644 index 0000000..4d18d43 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_boolean_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_box.png b/addons/material_maker/doc/images/node_sdf3d_box.png new file mode 100644 index 0000000..837d182 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_box.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_box_sample.png b/addons/material_maker/doc/images/node_sdf3d_box_sample.png new file mode 100644 index 0000000..c5ad91f Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_box_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_capsule.png b/addons/material_maker/doc/images/node_sdf3d_capsule.png new file mode 100644 index 0000000..96a2fda Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_capsule.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_capsule_sample.png b/addons/material_maker/doc/images/node_sdf3d_capsule_sample.png new file mode 100644 index 0000000..fcfa9e7 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_capsule_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_circlerepeat.png b/addons/material_maker/doc/images/node_sdf3d_circlerepeat.png new file mode 100644 index 0000000..4cb9004 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_circlerepeat.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_circlerepeat_sample.png b/addons/material_maker/doc/images/node_sdf3d_circlerepeat_sample.png new file mode 100644 index 0000000..682937c Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_circlerepeat_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_cone.png b/addons/material_maker/doc/images/node_sdf3d_cone.png new file mode 100644 index 0000000..da6f654 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_cone.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_cone_sample.png b/addons/material_maker/doc/images/node_sdf3d_cone_sample.png new file mode 100644 index 0000000..03644f5 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_cone_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_cylinder.png b/addons/material_maker/doc/images/node_sdf3d_cylinder.png new file mode 100644 index 0000000..584c7c9 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_cylinder.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_cylinder_sample.png b/addons/material_maker/doc/images/node_sdf3d_cylinder_sample.png new file mode 100644 index 0000000..e6d2ce3 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_cylinder_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_extrusion.png b/addons/material_maker/doc/images/node_sdf3d_extrusion.png new file mode 100644 index 0000000..4284f51 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_extrusion.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_extrusion_sample.png b/addons/material_maker/doc/images/node_sdf3d_extrusion_sample.png new file mode 100644 index 0000000..ec80091 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_extrusion_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_render.png b/addons/material_maker/doc/images/node_sdf3d_render.png new file mode 100644 index 0000000..d439a29 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_render.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_repeat.png b/addons/material_maker/doc/images/node_sdf3d_repeat.png new file mode 100644 index 0000000..d187979 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_repeat.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_repeat_sample.png b/addons/material_maker/doc/images/node_sdf3d_repeat_sample.png new file mode 100644 index 0000000..2280ff6 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_repeat_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_revolution.png b/addons/material_maker/doc/images/node_sdf3d_revolution.png new file mode 100644 index 0000000..2102b51 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_revolution.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_revolution_sample.png b/addons/material_maker/doc/images/node_sdf3d_revolution_sample.png new file mode 100644 index 0000000..7f717d4 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_revolution_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_rotate.png b/addons/material_maker/doc/images/node_sdf3d_rotate.png new file mode 100644 index 0000000..140c506 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_rotate.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_roundedshape.png b/addons/material_maker/doc/images/node_sdf3d_roundedshape.png new file mode 100644 index 0000000..bb0aff1 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_roundedshape.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_roundedshape_sample.png b/addons/material_maker/doc/images/node_sdf3d_roundedshape_sample.png new file mode 100644 index 0000000..d1192a4 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_roundedshape_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_samples.png b/addons/material_maker/doc/images/node_sdf3d_samples.png new file mode 100644 index 0000000..2a0af39 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_samples.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_scale.png b/addons/material_maker/doc/images/node_sdf3d_scale.png new file mode 100644 index 0000000..75cf7c5 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_scale.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_smoothboolean.png b/addons/material_maker/doc/images/node_sdf3d_smoothboolean.png new file mode 100644 index 0000000..58f5df2 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_smoothboolean.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_smoothboolean_sample.png b/addons/material_maker/doc/images/node_sdf3d_smoothboolean_sample.png new file mode 100644 index 0000000..59ccc1c Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_smoothboolean_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_sphere.png b/addons/material_maker/doc/images/node_sdf3d_sphere.png new file mode 100644 index 0000000..56551b0 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_sphere.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_sphere_sample.png b/addons/material_maker/doc/images/node_sdf3d_sphere_sample.png new file mode 100644 index 0000000..95bf65a Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_sphere_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_torus.png b/addons/material_maker/doc/images/node_sdf3d_torus.png new file mode 100644 index 0000000..b1ee336 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_torus.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_torus_sample.png b/addons/material_maker/doc/images/node_sdf3d_torus_sample.png new file mode 100644 index 0000000..e27eb07 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_torus_sample.png differ diff --git a/addons/material_maker/doc/images/node_sdf3d_translate.png b/addons/material_maker/doc/images/node_sdf3d_translate.png new file mode 100644 index 0000000..2e3e8f3 Binary files /dev/null and b/addons/material_maker/doc/images/node_sdf3d_translate.png differ diff --git a/addons/material_maker/doc/node_3d_sdf.rst b/addons/material_maker/doc/node_3d_sdf.rst new file mode 100644 index 0000000..bf7093c --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf.rst @@ -0,0 +1,69 @@ +3D signed distance function geometry nodes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The signed distance function nodes can be used to define complex 3D geometry using simple +shapes. + +They are based on a very small set of basic shapes, that can be combined using operators, +and finally output as a greyscale heightmap and a color normal map using the **render** node. + +Describing 3D objects using SDF primitives is more difficult than using existing meshes, but this +method integrates smoothly with shader generation, and (as many nodes in Material Maker) is +resolution independant. + +All output samples shown in this section are preview images. + +All Signed Distance Functions nodes are based on code written by Inigo Quilez that can be found +`on this page`__. + +.. _sdf3dpage: https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm + +__ sdf3dpage_ + +.. toctree:: + :maxdepth: 1 + + node_3d_sdf_render + +Shapes +++++++ + +.. toctree:: + :maxdepth: 1 + + node_3d_sdf_shapes_sphere + node_3d_sdf_shapes_box + node_3d_sdf_shapes_cylinder + node_3d_sdf_shapes_capsule + node_3d_sdf_shapes_cone + node_3d_sdf_shapes_torus + +Operators ++++++++++ + +.. toctree:: + :maxdepth: 1 + + node_3d_sdf_operators_boolean + node_3d_sdf_operators_smoothboolean + node_3d_sdf_operators_rounded + node_3d_sdf_operators_repeat + node_3d_sdf_operators_circlerepeat + node_3d_sdf_operators_extrusion + node_3d_sdf_operators_revolution + +Transforms +++++++++++ + +.. toctree:: + :maxdepth: 1 + + node_3d_sdf_transforms_translate + node_3d_sdf_transforms_scale + node_3d_sdf_transforms_rotate + +Example images +++++++++++++++ + +.. image:: images/node_sdf3d_samples.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_operators_boolean.rst b/addons/material_maker/doc/node_3d_sdf_operators_boolean.rst new file mode 100644 index 0000000..a845424 --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_operators_boolean.rst @@ -0,0 +1,31 @@ +Boolean node +............ + +The **Boolean** node generates a 3D signed distance function for the combination (union, +intersection or difference) of its inputs. + +.. image:: images/node_sdf3d_boolean.png + :align: center + +Inputs +:::::: + +The **Boolean** node accepts 2 inputs in 3D signed distance function format. + +Outputs +::::::: + +The **Boolean** node generates a signed distance function of the +combination of its inputs. + +Parameters +:::::::::: + +The **Boolean** node accepts *the operator it applies (union, intersection or +difference)* as parameter. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_boolean_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_operators_circlerepeat.rst b/addons/material_maker/doc/node_3d_sdf_operators_circlerepeat.rst new file mode 100644 index 0000000..3896379 --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_operators_circlerepeat.rst @@ -0,0 +1,30 @@ +CircleRepeat node +........... + +The **CircleRepeat** node generates a 3D signed distance image of a circular repetition of its +input. The source object must be offset in the positive Y direction from the center. + +.. image:: images/node_sdf3d_circlerepeat.png + :align: center + +Inputs +:::::: + +The **CircleRepeat** node accepts an input in 3D signed distance function format. + +Outputs +::::::: + +The **CircleRepeat** node generates a signed distance function of the +repeated version of the input shape. + +Parameters +:::::::::: + +The **CircleRepeat** node accepts *the number of repetitions* as parameter. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_circlerepeat_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_operators_extrusion.rst b/addons/material_maker/doc/node_3d_sdf_operators_extrusion.rst new file mode 100644 index 0000000..27d9e3b --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_operators_extrusion.rst @@ -0,0 +1,30 @@ +Extrusion node +.............. + +The **Extrusion** node generates a 3D signed distance function of a shape based on +its (2D signed function) input extruded along the Y axis. + +.. image:: images/node_sdf3d_extrusion.png + :align: center + +Inputs +:::::: + +The **Extrusion** node accepts an input in 2D signed distance function format. + +Outputs +::::::: + +The **Extrusion** node generates a signed distance function of the +extruded version of the input shape. + +Parameters +:::::::::: + +The **Extrusion** node accepts the *the length* of the extruded shape as parameter. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_extrusion_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_operators_repeat.rst b/addons/material_maker/doc/node_3d_sdf_operators_repeat.rst new file mode 100644 index 0000000..e62802c --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_operators_repeat.rst @@ -0,0 +1,34 @@ +Repeat node +........... + +The **Repeat** node generates a 3D signed distance image of a repetition of its +input on the X and Y axes. It can also apply a random rotation to the repeated +object instances. + +.. image:: images/node_sdf3d_repeat.png + :align: center + +Inputs +:::::: + +The **Repeat** node accepts an input in 3D signed distance function format. + +Outputs +::::::: + +The **Repeat** node generates a signed distance function of the +repeated version of the input shape. + +Parameters +:::::::::: + +The **Repeat** node accepts the following parameters: + +* *the repetition offset* for both X and Y axes +* *the amount of random rotation* applied to all instances + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_repeat_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_operators_revolution.rst b/addons/material_maker/doc/node_3d_sdf_operators_revolution.rst new file mode 100644 index 0000000..516a9de --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_operators_revolution.rst @@ -0,0 +1,30 @@ +Revolution node +............... + +The **Revolution** node generates a 3D signed distance function of a shape based on +the revolution along the Z axis of its (2D signed function) input. + +.. image:: images/node_sdf3d_revolution.png + :align: center + +Inputs +:::::: + +The **Revolution** node accepts an input in 2D signed distance function format. + +Outputs +::::::: + +The **Revolution** node generates a signed distance function of the +revolution of the input shape. + +Parameters +:::::::::: + +The **Revolution** node accepts the *the radius* of the revolution operation as parameter. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_revolution_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_operators_rounded.rst b/addons/material_maker/doc/node_3d_sdf_operators_rounded.rst new file mode 100644 index 0000000..7156fa6 --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_operators_rounded.rst @@ -0,0 +1,33 @@ +Rounded node +................. + +The **Rounded** node generates a 3D signed distance function of a rounded shape +based on its input, by substracting a constant from its input (i.e. +"growing" it towards the outside). + +.. image:: images/node_sdf3d_roundedshape.png + :align: center + +Inputs +:::::: + +The **Rounded** node accepts an input in 3D signed distance function format. + +Outputs +::::::: + +The **Rounded** node generates a signed distance function of the +rounded version of the input shape. + +Parameters +:::::::::: + +The **Rounded** node accepts the following parameters: + +* *the distance* to be substracted from the function + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_roundedshape_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_operators_smoothboolean.rst b/addons/material_maker/doc/node_3d_sdf_operators_smoothboolean.rst new file mode 100644 index 0000000..939806c --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_operators_smoothboolean.rst @@ -0,0 +1,33 @@ +SmoothBoolean node +.................. + +The **SmoothBoolean** node generates a 3D signed distance image for the combination (union, +intersection or difference) of its inputs. + +.. image:: images/node_sdf3d_smoothboolean.png + :align: center + +Inputs +:::::: + +The **SmoothBoolean** node accepts 2 inputs in signed distance function format. + +Outputs +::::::: + +The **SmoothBoolean** node generates a signed distance function of the +combination of its inputs. + +Parameters +:::::::::: + +The **SmoothBoolean** node accepts the following parameters: + +* *the operator it applies (union, intersection or difference)* +* *the smoothness* of the operation + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_smoothboolean_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_render.rst b/addons/material_maker/doc/node_3d_sdf_render.rst new file mode 100644 index 0000000..d63ba2a --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_render.rst @@ -0,0 +1,27 @@ +Render node +........... + +The **Render** node generates images from a 3D signed distance function inputs. + +.. image:: images/node_sdf3d_render.png + :align: center + +Inputs +:::::: + +The **Render** node accepts an input in 3D signed distance function format. + +Outputs +::::::: + +The **Render** node generates two images from its input: + +* a *height map* of the rendered input along the Z axis +* a *normal map* of the rendered input calculated directly + using the 3D signed function (and consequently more + accurate than a normal map generated from the height map) + +Parameters +:::::::::: + +The **Render** node does no accept any parameter. diff --git a/addons/material_maker/doc/node_3d_sdf_shapes_box.rst b/addons/material_maker/doc/node_3d_sdf_shapes_box.rst new file mode 100644 index 0000000..f248317 --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_shapes_box.rst @@ -0,0 +1,31 @@ +Box node +........ + +The **Box** node generates a 3d signed distance function for a box with rounded corners. + +.. image:: images/node_sdf3d_box.png + :align: center + +Inputs +:::::: + +The **Box** node does not accept any input. + +Outputs +::::::: + +The **Box** node generates a signed distance function for a box. + +Parameters +:::::::::: + +The **Box** node accepts the following parameters: + +* the X, Y and Z sizes of the box (not including the rounded corners and edges) +* the radius of the rounded corners and edges + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_box_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_shapes_capsule.rst b/addons/material_maker/doc/node_3d_sdf_shapes_capsule.rst new file mode 100644 index 0000000..15dc04d --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_shapes_capsule.rst @@ -0,0 +1,28 @@ +Capsule node +............ + +The **Capsule** node generates a 3d signed distance function for a capsule. + +.. image:: images/node_sdf3d_capsule.png + :align: center + +Inputs +:::::: + +The **Capsule** node does not accept any input. + +Outputs +::::::: + +The **Capsule** node generates a signed distance function for a capsule. + +Parameters +:::::::::: + +The **Capsule** node accepts as parameters the length of the capsule and its radius. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_capsule_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_shapes_cone.rst b/addons/material_maker/doc/node_3d_sdf_shapes_cone.rst new file mode 100644 index 0000000..15dc04d --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_shapes_cone.rst @@ -0,0 +1,28 @@ +Capsule node +............ + +The **Capsule** node generates a 3d signed distance function for a capsule. + +.. image:: images/node_sdf3d_capsule.png + :align: center + +Inputs +:::::: + +The **Capsule** node does not accept any input. + +Outputs +::::::: + +The **Capsule** node generates a signed distance function for a capsule. + +Parameters +:::::::::: + +The **Capsule** node accepts as parameters the length of the capsule and its radius. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_capsule_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_shapes_cylinder.rst b/addons/material_maker/doc/node_3d_sdf_shapes_cylinder.rst new file mode 100644 index 0000000..409d9dc --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_shapes_cylinder.rst @@ -0,0 +1,28 @@ +Cylinder node +............. + +The **Cylinder** node generates a 3d signed distance function for a cylinder. + +.. image:: images/node_sdf3d_cylinder.png + :align: center + +Inputs +:::::: + +The **Cylinder** node does not accept any input. + +Outputs +::::::: + +The **Cylinder** node generates a signed distance function for a cylinder. + +Parameters +:::::::::: + +The **Cylinder** node accepts as parameters the length of the cylinder and its radius. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_cylinder_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_shapes_sphere.rst b/addons/material_maker/doc/node_3d_sdf_shapes_sphere.rst new file mode 100644 index 0000000..827670c --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_shapes_sphere.rst @@ -0,0 +1,28 @@ +Sphere node +........... + +The **Sphere** node generates a 3d signed distance function for a sphere. + +.. image:: images/node_sdf3d_sphere.png + :align: center + +Inputs +:::::: + +The **Sphere** node does not accept any input. + +Outputs +::::::: + +The **Sphere** node generates a signed distance function for a sphere. + +Parameters +:::::::::: + +The **Sphere** node accepts a single parameter, its radius. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_sphere_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_shapes_torus.rst b/addons/material_maker/doc/node_3d_sdf_shapes_torus.rst new file mode 100644 index 0000000..7d276b7 --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_shapes_torus.rst @@ -0,0 +1,28 @@ +Torus node +.......... + +The **Torus** node generates a 3d signed distance function for a torus. + +.. image:: images/node_sdf3d_torus.png + :align: center + +Inputs +:::::: + +The **Torus** node does not accept any input. + +Outputs +::::::: + +The **Torus** node generates a signed distance function for a torus. + +Parameters +:::::::::: + +The **Torus** node accepts as parameters both radiuses of the torus. + +Example images +:::::::::::::: + +.. image:: images/node_sdf3d_torus_sample.png + :align: center diff --git a/addons/material_maker/doc/node_3d_sdf_transforms_rotate.rst b/addons/material_maker/doc/node_3d_sdf_transforms_rotate.rst new file mode 100644 index 0000000..4b7cc1c --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_transforms_rotate.rst @@ -0,0 +1,24 @@ +Rotate node +........... + +The **Rotate** node generates a 3D signed distance function of a rotated shape +based on its input. + +.. image:: images/node_sdf3d_rotate.png + :align: center + +Inputs +:::::: + +The **Rotate** node accepts an input in 3D signed distance function format. + +Outputs +::::::: + +The **Rotate** node generates a signed distance function of the +rotated input shape. + +Parameters +:::::::::: + +The **Rotate** node accepts *the angles of the rotations around the X, Y and Z axes* as parameters. diff --git a/addons/material_maker/doc/node_3d_sdf_transforms_scale.rst b/addons/material_maker/doc/node_3d_sdf_transforms_scale.rst new file mode 100644 index 0000000..b708917 --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_transforms_scale.rst @@ -0,0 +1,24 @@ +Scale node +.......... + +The **Scale** node generates a 3D signed distance function of a scaled shape +based on its input. + +.. image:: images/node_sdf3d_scale.png + :align: center + +Inputs +:::::: + +The **Scale** node accepts an input in 3D signed distance function format. + +Outputs +::::::: + +The **Scale** node generates a signed distance function of the +scaled input shape. + +Parameters +:::::::::: + +The **Scale** node accepts *its scale factor* as parameters. diff --git a/addons/material_maker/doc/node_3d_sdf_transforms_translate.rst b/addons/material_maker/doc/node_3d_sdf_transforms_translate.rst new file mode 100644 index 0000000..b577f05 --- /dev/null +++ b/addons/material_maker/doc/node_3d_sdf_transforms_translate.rst @@ -0,0 +1,24 @@ +Translate node +.............. + +The **Translate** node generates a 3D signed distance function of a translated shape +based on its input. + +.. image:: images/node_sdf3d_translate.png + :align: center + +Inputs +:::::: + +The **Translate** node accepts an input in 3D signed distance function format. + +Outputs +::::::: + +The **Translate** node generates a signed distance function of the +translated input shape. + +Parameters +:::::::::: + +The **Translate** node accepts *the X, Y and Z components of the translation* as parameters. diff --git a/addons/material_maker/doc/node_simple_sdf.rst b/addons/material_maker/doc/node_simple_sdf.rst index 53aaebd..8c789c3 100644 --- a/addons/material_maker/doc/node_simple_sdf.rst +++ b/addons/material_maker/doc/node_simple_sdf.rst @@ -1,5 +1,5 @@ -Signed distance function geometry nodes -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +2D Signed distance function geometry nodes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The signed distance function nodes can be used to define complex geometry using simple shapes. @@ -7,7 +7,7 @@ shapes. They are based on a very small set of basic shapes, that can be combined using operators, and finally output as a greyscale image using the **sdShow** node. -All output samples shown in this sections are images generated through the **sdView** node. +All output samples shown in this sections are images generated through the **sdShow** node. All Signed Distance Functions nodes are based on code written by Inigo Quilez that can be found `on this page`__. diff --git a/addons/material_maker/doc/nodes_3d.rst b/addons/material_maker/doc/nodes_3d.rst new file mode 100644 index 0000000..31c3f90 --- /dev/null +++ b/addons/material_maker/doc/nodes_3d.rst @@ -0,0 +1,10 @@ +3D nodes +-------- + +The simple nodes are nodes that do not accept any input and generate one or several simple shapes. + +.. toctree:: + :maxdepth: 0 + + node_3d_sdf + \ No newline at end of file diff --git a/addons/material_maker/doc/subgraph_nodes.rst b/addons/material_maker/doc/subgraph_nodes.rst index 88cd3b3..6d96c9f 100644 --- a/addons/material_maker/doc/subgraph_nodes.rst +++ b/addons/material_maker/doc/subgraph_nodes.rst @@ -21,11 +21,12 @@ shortcut will make it possible to edit its contents using the pencil button. The newly created subgraph contains: * all nodes that have been grouped -* an **Input** and an **Output** node that rep^resent the inputs and the outputs +* an **Input** and an **Output** node that represent the inputs and the outputs of the subgraph. Selecting them and using the **Control+W** shortcut makes them - editable so the subgraph inputs and outputs can be added, removed reordered or - renamed. Please note that all those operations will (when possible) keep - connectivity inside and outside the subgraph. + editable so the subgraph inputs and outputs can be added, removed, reordered, + renamed or have their types modified. + Please note that all those operations will (when possible) keep connectivity + inside and outside the subgraph. * A **Parameters** node that is a **remote** can be edited to expose selected parameters to the parent graph. When grouping nodes with a **remote**, the remote will automatically be used as **Parameters** node in the nealy created diff --git a/addons/material_maker/engine/gen_base.gd b/addons/material_maker/engine/gen_base.gd index 5cb42a2..a85fd13 100644 --- a/addons/material_maker/engine/gen_base.gd +++ b/addons/material_maker/engine/gen_base.gd @@ -37,6 +37,17 @@ var parameters = {} var seed_locked : bool = false var seed_value : int = 0 +const PORT_TYPE_NAMES : Array = [ "f", "rgb", "rgba", "sdf2d", "sdf3d" ] + +const PORT_TYPES : Dictionary = { + f = { type="float", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.5, 0.5, 0.5) }, + rgb = { type="vec3", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.5, 0.5, 1.0) }, + rgba = { type="vec4", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.0, 0.5, 0.0, 0.5) }, + sdf2d = { type="float", paramdefs="vec2 uv", params="uv", slot_type=1, color=Color(1.0, 0.5, 0.0) }, + sdf3d = { type="float", paramdefs="vec3 p", params="p", slot_type=2, color=Color(1.0, 0.0, 0.0) }, + any = { slot_type=42, color=Color(1.0, 1.0, 1.0) } +} + func _ready() -> void: init_parameters() @@ -151,14 +162,18 @@ func get_input_shader(input_index : int) -> Dictionary: func get_shader(output_index : int, context) -> Dictionary: return get_shader_code("UV", output_index, context) -func render(output_index : int, size : int) -> Object: +func render(output_index : int, size : int, preview : bool = false) -> Object: var context : MMGenContext = MMGenContext.new() - var source = get_shader_code("UV", output_index, context) + var source = get_shader_code("uv", output_index, context) while source is GDScriptFunctionState: source = yield(source, "completed") if source.empty(): source = { defs="", code="", textures={}, rgba="vec4(0.0)" } - var shader : String = mm_renderer.generate_shader(source) + var shader : String + if preview: + shader = mm_renderer.generate_preview_shader(source) + else: + shader = mm_renderer.generate_shader(source) var result = mm_renderer.render_shader(shader, source.textures, size) while result is GDScriptFunctionState: result = yield(result, "completed") @@ -174,15 +189,14 @@ func get_shader_code(uv : String, output_index : int, context : MMGenContext) -> rv.f = "(dot("+rv.rgb+", vec3(1.0))/3.0)" elif rv.has("rgba"): rv.f = "(dot("+rv.rgba+".rgb, vec3(1.0))/3.0)" - else: - rv.f = "0.0" if !rv.has("rgb"): if rv.has("rgba"): rv.rgb = rv.rgba+".rgb" - else: + elif rv.has("f"): rv.rgb = "vec3("+rv.f+")" if !rv.has("rgba"): - rv.rgba = "vec4("+rv.rgb+", 1.0)" + if rv.has("rgb"): + rv.rgba = "vec4("+rv.rgb+", 1.0)" return rv func _get_shader_code(__, __, __) -> Dictionary: diff --git a/addons/material_maker/engine/gen_context.gd b/addons/material_maker/engine/gen_context.gd index 068574c..827ae33 100644 --- a/addons/material_maker/engine/gen_context.gd +++ b/addons/material_maker/engine/gen_context.gd @@ -4,10 +4,19 @@ class_name MMGenContext var variants : Dictionary = {} +var parent_context : MMGenContext = null +func _init(p = null) -> void: + parent_context = p func has_variant(generator) -> bool: - return variants.has(generator) + return variants.has(generator) or parent_context != null and parent_context.has_variant(generator) + +func touch_variant(generator) -> void: + if !variants.has(generator): + variants[generator] = [] + if parent_context != null: + parent_context.touch_variant(generator) func get_variant(generator, variant) -> int: var rv = -1 @@ -17,4 +26,5 @@ func get_variant(generator, variant) -> int: variants[generator].push_back(variant) else: variants[generator] = [variant] + touch_variant(generator) return rv diff --git a/addons/material_maker/engine/gen_graph.gd b/addons/material_maker/engine/gen_graph.gd index e0be616..078d8eb 100644 --- a/addons/material_maker/engine/gen_graph.gd +++ b/addons/material_maker/engine/gen_graph.gd @@ -284,8 +284,8 @@ func create_subgraph(gens : Array) -> MMGenGraph: if port_index == -1: port_index = outputs.size() outputs.push_back(src_name) - gen_outputs.ports.push_back( { name="port"+str(port_index), type="rgba" } ) - print(gen_outputs.ports) + var type = new_graph.get_node(c.from).get_output_defs()[c.from_port].type + gen_outputs.ports.push_back( { name="port"+str(port_index), type=type } ) my_new_connections.push_back( { from=new_graph.name, from_port=port_index, to=c.to, to_port=c.to_port } ) new_graph_connections.push_back( { from=c.from, from_port=c.from_port, to="gen_outputs", to_port=port_index } ) elif names.find(c.to) != -1: @@ -293,7 +293,8 @@ func create_subgraph(gens : Array) -> MMGenGraph: if port_index == -1: port_index = inputs.size() inputs.push_back(src_name) - gen_inputs.ports.push_back( { name="port"+str(port_index), type="rgba" } ) + var type = get_node(c.from).get_output_defs()[c.from_port].type + gen_inputs.ports.push_back( { name="port"+str(port_index), type=type } ) my_new_connections.push_back( { from=c.from, from_port=c.from_port, to=new_graph.name, to_port=port_index } ) new_graph_connections.push_back( { from="gen_inputs", from_port=port_index, to=c.to, to_port=c.to_port } ) else: diff --git a/addons/material_maker/engine/gen_ios.gd b/addons/material_maker/engine/gen_ios.gd index 4222bff..d7d30fe 100644 --- a/addons/material_maker/engine/gen_ios.gd +++ b/addons/material_maker/engine/gen_ios.gd @@ -27,7 +27,7 @@ func get_type_name() -> String: func get_io_defs() -> Array: var rv : Array = [] for p in ports: - rv.push_back({ name=p.name, type="rgba" }) + rv.push_back({ name=p.name, type=p.type }) return rv func get_input_defs() -> Array: @@ -54,6 +54,11 @@ func add_port() -> void: func set_port_name(i : int, n : String) -> void: ports[i].name = n +func set_port_type(i : int, t : String) -> void: + print(t) + ports[i].type = t + emit_signal("parameter_changed", "__update_all__", null) + func delete_port(i : int) -> void: ports.remove(i) var input_gen = get_parent() if name == "gen_inputs" else self diff --git a/addons/material_maker/engine/gen_shader.gd b/addons/material_maker/engine/gen_shader.gd index e4d750a..cad14cb 100644 --- a/addons/material_maker/engine/gen_shader.gd +++ b/addons/material_maker/engine/gen_shader.gd @@ -2,11 +2,13 @@ tool extends MMGenBase class_name MMGenShader + var shader_model : Dictionary = {} var uses_seed = false var editable = false + func toggle_editable() -> bool: editable = !editable if editable: @@ -53,16 +55,12 @@ func set_shader_model(data: Dictionary) -> void: for i in range(shader_model.outputs.size()): var output = shader_model.outputs[i] var output_code = "" - if output.has("rgba"): - shader_model.outputs[i].type = "rgba" - output_code = output.rgba - elif output.has("rgb"): - shader_model.outputs[i].type = "rgb" - output_code = output.rgb - elif output.has("f"): - shader_model.outputs[i].type = "f" - output_code = output.f - else: + for f in PORT_TYPES.keys(): + if output.has(f): + shader_model.outputs[i].type = f + output_code = output[f] + break + if output_code == "": print("Unsupported output type") if output_code.find("$seed") != -1 or output_code.find("$(seed)") != -1: uses_seed = true @@ -90,7 +88,19 @@ func find_keyword_call(string, keyword): parenthesis_level -= 1 return "" -func replace_input(string, context, input, type, src, default) -> Dictionary: +func replace_input_with_function_call(string : String, input : String) -> String: + var genname = "o"+str(get_instance_id()) + while true: + var uv = find_keyword_call(string, input) + if uv == null: + break + elif uv == "": + print("syntax error") + break + string = string.replace("$%s(%s)" % [ input, uv ], "%s_input_%s(%s)" % [ genname, input, uv ]) + return string + +func replace_input(string : String, context, input : String, type : String, src : OutputPort, default : String) -> Dictionary: var required_globals = [] var required_defs = "" var required_code = "" @@ -113,7 +123,10 @@ func replace_input(string, context, input, type, src, default) -> Dictionary: src_code = src.generator.get_shader_code(uv, src.output_index, context) while src_code is GDScriptFunctionState: src_code = yield(src_code, "completed") - src_code.string = src_code[type] + if src_code.has(type): + src_code.string = src_code[type] + else: + src_code.string = "*error*" # Add global definitions if src_code.has("globals"): for d in src_code.globals: @@ -134,7 +147,7 @@ func replace_input(string, context, input, type, src, default) -> Dictionary: func is_word_letter(l) -> bool: return "azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890_".find(l) != -1 -func replace_variable(string, variable, value) -> String: +func replace_variable(string : String, variable : String, value : String) -> String: string = string.replace("$(%s)" % variable, value) var keyword_size = variable.length()+1 var new_string = "" @@ -152,7 +165,7 @@ func replace_variable(string, variable, value) -> String: string = string.right(keyword_size) return new_string -func subst(string, context, uv = "") -> Dictionary: +func subst(string : String, context : MMGenContext, uv : String = "") -> Dictionary: var genname = "o"+str(get_instance_id()) var required_globals = [] var required_defs = "" @@ -199,40 +212,41 @@ func subst(string, context, uv = "") -> Dictionary: for i in range(shader_model.inputs.size()): var input = shader_model.inputs[i] var source = get_source(i) - var result = replace_input(string, context, input.name, input.type, source, input.default) - while result is GDScriptFunctionState: - result = yield(result, "completed") - if string != result.string: - changed = true - if result.new_pass_required: - new_pass_required = true - string = result.string - # Add global definitions - for d in result.globals: - if required_globals.find(d) == -1: - required_globals.push_back(d) - # Add generated definitions - required_defs += result.defs - # Add generated code - required_code += result.code - for t in result.textures.keys(): - required_textures[t] = result.textures[t] + if input.has("function") and input.function: + string = replace_input_with_function_call(string, input.name) + else: + var result = replace_input(string, context, input.name, input.type, source, input.default) + while result is GDScriptFunctionState: + result = yield(result, "completed") + if string != result.string: + changed = true + if result.new_pass_required: + new_pass_required = true + string = result.string + # Add global definitions + for d in result.globals: + if required_globals.find(d) == -1: + required_globals.push_back(d) + # Add generated definitions + required_defs += result.defs + # Add generated code + required_code += result.code + for t in result.textures.keys(): + required_textures[t] = result.textures[t] cont = changed and new_pass_required return { string=string, globals=required_globals, defs=required_defs, code=required_code, textures=required_textures } +func create_input_function(function_name : String, input_index : int, context : MMGenContext) -> Dictionary: + var rv = { globals=[], defs="", code="", textures={} } + return rv + func _get_shader_code(uv : String, output_index : int, context : MMGenContext) -> Dictionary: var genname = "o"+str(get_instance_id()) - var output_info = [ { field="rgba", type="vec4" }, { field="rgb", type="vec3" }, { field="f", type="float" } ] var rv = { globals=[], defs="", code="", textures={} } if shader_model != null and shader_model.has("outputs") and shader_model.outputs.size() > output_index: var output = shader_model.outputs[output_index] - if shader_model.has("instance") && !context.has_variant(self): - var subst_output = subst(shader_model.instance, context, "") - while subst_output is GDScriptFunctionState: - subst_output = yield(subst_output, "completed") - rv.defs += subst_output.string - for t in subst_output.textures.keys(): - rv.textures[t] = subst_output.textures[t] + if !context.has_variant(self): + # Generate functions for gradients for p in shader_model.parameters: if p.type == "gradient": var g = parameters[p.name] @@ -240,6 +254,37 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext) - g = MMGradient.new() g.deserialize(parameters[p.name]) rv.defs += g.get_shader(genname+"_p_"+p.name+"_gradient_fct") + # Generate functions for inputs + if shader_model.has("inputs"): + for i in range(shader_model.inputs.size()): + var input = shader_model.inputs[i] + if input.has("function") and input.function: + var source = get_source(i) + var string = "$%s(%s)" % [ input.name, PORT_TYPES[input.type].params ] + var local_context = MMGenContext.new(context) + var result = replace_input(string, local_context, input.name, input.type, source, input.default) + while result is GDScriptFunctionState: + result = yield(result, "completed") + # Add global definitions + for d in result.globals: + if rv.globals.find(d) == -1: + rv.globals.push_back(d) + # Add generated definitions + rv.defs += result.defs + # Add textures + for t in result.textures.keys(): + rv.textures[t] = result.textures[t] + rv.defs += "%s %s_input_%s(%s) {\n" % [ PORT_TYPES[input.type].type, genname, input.name, PORT_TYPES[input.type].paramdefs ] + rv.defs += "%s\n" % result.code + rv.defs += "return %s;\n}\n" % result.string + if shader_model.has("instance"): + var subst_output = subst(shader_model.instance, context, "") + while subst_output is GDScriptFunctionState: + subst_output = yield(subst_output, "completed") + rv.defs += subst_output.string + # process textures + for t in subst_output.textures.keys(): + rv.textures[t] = subst_output.textures[t] # Add inline code if shader_model.has("code"): var variant_index = context.get_variant(self, uv) @@ -262,9 +307,9 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext) - var variant_index = context.get_variant(self, variant_string) if variant_index == -1: variant_index = context.get_variant(self, variant_string) - for t in output_info: - if output.has(t.field): - var subst_output = subst(output[t.field], context, uv) + for f in PORT_TYPES.keys(): + if output.has(f): + var subst_output = subst(output[f], context, uv) while subst_output is GDScriptFunctionState: subst_output = yield(subst_output, "completed") # Add global definitions @@ -275,12 +320,12 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext) - rv.defs += subst_output.defs # Add generated code rv.code += subst_output.code - rv.code += "%s %s_%d_%d_%s = %s;\n" % [ t.type, genname, output_index, variant_index, t.field, subst_output.string ] + rv.code += "%s %s_%d_%d_%s = %s;\n" % [ PORT_TYPES[f].type, genname, output_index, variant_index, f, subst_output.string ] for t in subst_output.textures.keys(): rv.textures[t] = subst_output.textures[t] - for t in output_info: - if output.has(t.field): - rv[t.field] = "%s_%d_%d_%s" % [ genname, output_index, variant_index, t.field ] + for f in PORT_TYPES.keys(): + if output.has(f): + rv[f] = "%s_%d_%d_%s" % [ genname, output_index, variant_index, f ] if shader_model.has("global") && rv.globals.find(shader_model.global) == -1: rv.globals.push_back(shader_model.global) return rv diff --git a/addons/material_maker/engine/gen_switch.gd b/addons/material_maker/engine/gen_switch.gd index 5a48ab5..d17e246 100644 --- a/addons/material_maker/engine/gen_switch.gd +++ b/addons/material_maker/engine/gen_switch.gd @@ -34,14 +34,14 @@ func get_input_defs() -> Array: for c in range(parameters.choices): for o in range(parameters.outputs): var n = PoolByteArray([65+o]).get_string_from_ascii()+str(c) - rv.push_back({ name=n, label=n, type="rgba" }) + rv.push_back({ name=n, label=n, type="any" }) return rv func get_output_defs() -> Array: var rv : Array = [] for o in range(parameters.outputs): var n = PoolByteArray([65+o]).get_string_from_ascii() - rv.push_back({ name=n, type="rgba" }) + rv.push_back({ name=n, type="any" }) return rv func set_parameter(p, v) -> void: diff --git a/addons/material_maker/engine/renderer.gd b/addons/material_maker/engine/renderer.gd index 667be6c..94e0fd6 100644 --- a/addons/material_maker/engine/renderer.gd +++ b/addons/material_maker/engine/renderer.gd @@ -27,13 +27,86 @@ static func generate_shader(src_code) -> String: code += g var shader_code = src_code.defs shader_code += "\nvoid fragment() {\n" + shader_code += "vec2 uv = UV;\n" shader_code += src_code.code - shader_code += "COLOR = "+src_code.rgba+";\n" + if src_code.has("rgba"): + shader_code += "COLOR = "+src_code.rgba+";\n" + else: + shader_code += "COLOR = vec4(1.0, 0.0, 0.0, 1.0);\n" shader_code += "}\n" #print("GENERATED SHADER:\n"+shader_code) code += shader_code return code +static func generate_preview_shader(src_code) -> String: + var code + code = "shader_type canvas_item;\n" + code += "render_mode blend_disabled;\n" + code += "uniform float preview_size = 64;\n" + var file = File.new() + file.open("res://addons/material_maker/common.shader", File.READ) + code += file.get_as_text() + code += "\n" + if src_code.has("textures"): + for t in src_code.textures.keys(): + code += "uniform sampler2D "+t+";\n" + if src_code.has("globals"): + for g in src_code.globals: + code += g + var shader_code = src_code.defs + if src_code.has("rgba"): + shader_code += "\nvoid fragment() {\n" + shader_code += "vec2 uv = UV;\n" + shader_code += src_code.code + shader_code += "COLOR = "+src_code.rgba+";\n" + shader_code += "}\n" + elif src_code.has("sdf2d"): + shader_code += "\nvoid fragment() {\n" + shader_code += "vec2 uv = UV;\n" + shader_code += src_code.code + shader_code += "float d = "+src_code.sdf2d+";\n" + shader_code += "vec3 col = vec3(cos(d*min(256, preview_size)));\n" + shader_code += "col *= clamp(1.0-d*d, 0.0, 1.0);\n" + shader_code += "col *= vec3(1.0, vec2(step(-0.015, d)));\n" + shader_code += "col *= vec3(vec2(step(d, 0.015)), 1.0);\n" + shader_code += "COLOR = vec4(col, 1.0);\n" + shader_code += "}\n" + elif src_code.has("sdf3d"): + shader_code += "\nfloat calcdist(vec3 uv) {\n" + shader_code += src_code.code + shader_code += "return min("+src_code.sdf3d+", uv.z);\n" + shader_code += "}\n" + shader_code += "float raymarch(vec3 ro, vec3 rd) {\n" + shader_code += "float d=0.0;\n" + shader_code += "for (int i = 0; i < 50; i++) {\n" + shader_code += "vec3 p = ro + rd*d;\n" + shader_code += "float dstep = calcdist(p);\n" + shader_code += "d += dstep;\n" + shader_code += "if (dstep < 0.0001) break;\n" + shader_code += "}\n" + shader_code += "return d;\n" + shader_code += "}\n" + shader_code += "vec3 normal(vec3 p) {\n" + shader_code += " float d = calcdist(p);\n" + shader_code += " float e = .0001;\n" + shader_code += " vec3 n = d - vec3(calcdist(p-vec3(e, 0.0, 0.0)), calcdist(p-vec3(0.0, e, 0.0)), calcdist(p-vec3(0.0, 0.0, e)));\n" + shader_code += " return normalize(n);\n" + shader_code += "}\n" + shader_code += "\nvoid fragment() {\n" + shader_code += "vec2 uv = UV-vec2(0.5);\n" + shader_code += "vec3 p = vec3(uv, 2.0-raymarch(vec3(uv, 2.0), vec3(0.0, 0.0, -1.0)));\n" + shader_code += "vec3 n = normal(p);\n" + shader_code += "vec3 l = vec3(5.0, 5.0, 10.0);\n" + shader_code += "vec3 ld = normalize(l-p);\n" + shader_code += "float o = step(p.z, 0.001);\n" + shader_code += "float shadow = 1.0-0.75*step(raymarch(l, -ld), length(l-p)-0.01);\n" + shader_code += "float light = 0.3+0.7*dot(n, ld)*shadow;\n" + shader_code += "COLOR = vec4(vec3(0.8+0.2*o, 0.8+0.2*o, 1.0)*light, 1.0);\n" + shader_code += "}\n" + #print("GENERATED SHADER:\n"+shader_code) + code += shader_code + return code + static func generate_combined_shader(red_code, green_code, blue_code) -> String: var code code = "shader_type canvas_item;\n" @@ -44,6 +117,7 @@ static func generate_combined_shader(red_code, green_code, blue_code) -> String: code += "\n" var globals = [] var textures = {} + var output = [] for c in [ red_code, green_code, blue_code ]: if c.has("textures"): for t in c.textures.keys(): @@ -52,6 +126,10 @@ static func generate_combined_shader(red_code, green_code, blue_code) -> String: for g in c.globals: if globals.find(g) == -1: globals.push_back(g) + if c.has("f"): + output.push_back(c.f) + else: + output.push_back("1.0") for t in textures.keys(): code += "uniform sampler2D "+t+";\n" for g in globals: @@ -64,7 +142,7 @@ static func generate_combined_shader(red_code, green_code, blue_code) -> String: shader_code += red_code.code shader_code += green_code.code shader_code += blue_code.code - shader_code += "COLOR = vec4("+red_code.f+", "+green_code.f+", "+blue_code.f+", 1.0);\n" + shader_code += "COLOR = vec4("+output[0]+", "+output[1]+", "+output[2]+", 1.0);\n" shader_code += "}\n" #print("GENERATED COMBINED SHADER:\n"+shader_code) code += shader_code @@ -95,6 +173,7 @@ func render_shader(shader, textures, render_size) -> Object: if textures != null: for k in textures.keys(): shader_material.set_shader_param(k, textures[k]) + shader_material.set_shader_param("preview_size", render_size) render_target_update_mode = Viewport.UPDATE_ONCE update_worlds() yield(get_tree(), "idle_frame") diff --git a/addons/material_maker/examples/doc_tools.ptex b/addons/material_maker/examples/doc_tools.ptex index 763ecfb..bbb597c 100644 --- a/addons/material_maker/examples/doc_tools.ptex +++ b/addons/material_maker/examples/doc_tools.ptex @@ -1,35 +1,5 @@ { "connections": [ - { - "from": "graph_5", - "from_port": 0, - "to": "graph", - "to_port": 3 - }, - { - "from": "graph_4", - "from_port": 0, - "to": "graph", - "to_port": 2 - }, - { - "from": "perlin_color_2", - "from_port": 0, - "to": "graph", - "to_port": 1 - }, - { - "from": "perlin_color", - "from_port": 0, - "to": "graph", - "to_port": 0 - }, - { - "from": "graph", - "from_port": 0, - "to": "Material", - "to_port": 0 - }, { "from": "bricks", "from_port": 0, @@ -71,6 +41,60 @@ "from_port": 0, "to": "blend", "to_port": 2 + }, + { + "from": "graph", + "from_port": 0, + "to": "Material", + "to_port": 0 + }, + { + "from": "raymarching_2", + "from_port": 0, + "to": "graph", + "to_port": 0 + }, + { + "from": "raymarching_2", + "from_port": 1, + "to": "graph", + "to_port": 1 + }, + { + "from": "raymarching_2_2", + "from_port": 0, + "to": "graph", + "to_port": 2 + }, + { + "from": "raymarching_2_2", + "from_port": 1, + "to": "graph", + "to_port": 3 + }, + { + "from": "graph_3_2", + "from_port": 0, + "to": "raymarching_2", + "to_port": 0 + }, + { + "from": "graph_4", + "from_port": 0, + "to": "sdf3d_rotate_2", + "to_port": 0 + }, + { + "from": "sdf3d_rotate_2", + "from_port": 0, + "to": "sdf3d_translate_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2", + "from_port": 0, + "to": "raymarching_2_2", + "to_port": 0 } ], "label": "Graph", @@ -100,7 +124,7 @@ "metallic": 1, "normal_scale": 1, "roughness": 1, - "size": 9, + "size": 8, "subsurf_scatter_strength": 0 }, "type": "material" @@ -225,8 +249,8 @@ "label": "Tile Inputs", "name": "graph", "node_position": { - "x": 228.541992, - "y": -110.733459 + "x": 237.541992, + "y": 78.266541 }, "nodes": [ { @@ -506,7 +530,7 @@ "name": "graph_2", "node_position": { "x": 206.827515, - "y": 280.753479 + "y": 279.753479 }, "nodes": [ { @@ -930,456 +954,6 @@ }, "type": "graph" }, - { - "name": "perlin_color", - "node_position": { - "x": -220.835205, - "y": -401.150269 - }, - "parameters": { - "iterations": 3, - "persistence": 0.5, - "scale_x": 4, - "scale_y": 4 - }, - "type": "perlin_color" - }, - { - "name": "perlin_color_2", - "node_position": { - "x": -216.835205, - "y": -273.150269 - }, - "parameters": { - "iterations": 6, - "persistence": 0.9, - "scale_x": 4, - "scale_y": 4 - }, - "type": "perlin_color" - }, - { - "connections": [ - { - "from": "perlin", - "from_port": 0, - "to": "transform", - "to_port": 1 - }, - { - "from": "perlin", - "from_port": 0, - "to": "transform", - "to_port": 2 - }, - { - "from": "perlin", - "from_port": 0, - "to": "transform", - "to_port": 0 - }, - { - "from": "transform", - "from_port": 0, - "to": "gen_outputs", - "to_port": 0 - } - ], - "label": "Warp1", - "name": "graph_4", - "node_position": { - "x": -214.835205, - "y": -147.150269 - }, - "nodes": [ - { - "name": "transform", - "node_position": { - "x": -259.25, - "y": -658 - }, - "parameters": { - "repeat": false, - "rotate": 0, - "scale_x": 1, - "scale_y": 1, - "translate_x": 0.5, - "translate_y": 0.5 - }, - "type": "transform" - }, - { - "name": "perlin", - "node_position": { - "x": -502.25, - "y": -653 - }, - "parameters": { - "iterations": 3, - "persistence": 0.5, - "scale_x": 4, - "scale_y": 4 - }, - "type": "perlin" - }, - { - "name": "gen_inputs", - "node_position": { - "x": -670.25, - "y": -647.5 - }, - "parameters": { - - }, - "ports": [ - - ], - "type": "ios" - }, - { - "name": "gen_outputs", - "node_position": { - "x": 18.75, - "y": -657.5 - }, - "parameters": { - - }, - "ports": [ - { - "name": "port0", - "type": "rgba" - } - ], - "type": "ios" - }, - { - "name": "gen_parameters", - "node_position": { - "x": -315.75, - "y": -893 - }, - "parameters": { - "param0": 4, - "param1": 4, - "param2": 3, - "param3": 0.5, - "param4": 0.5, - "param5": 0.5 - }, - "type": "remote", - "widgets": [ - { - "label": "Scale X", - "linked_widgets": [ - { - "node": "perlin", - "widget": "scale_x" - } - ], - "name": "param0", - "type": "linked_control" - }, - { - "label": "Scale Y", - "linked_widgets": [ - { - "node": "perlin", - "widget": "scale_y" - } - ], - "name": "param1", - "type": "linked_control" - }, - { - "label": "Iterations", - "linked_widgets": [ - { - "node": "perlin", - "widget": "iterations" - } - ], - "name": "param2", - "type": "linked_control" - }, - { - "label": "Persistance", - "linked_widgets": [ - { - "node": "perlin", - "widget": "persistence" - } - ], - "name": "param3", - "type": "linked_control" - }, - { - "label": "Warp X", - "linked_widgets": [ - { - "node": "transform", - "widget": "translate_x" - } - ], - "name": "param4", - "type": "linked_control" - }, - { - "label": "Warp Y", - "linked_widgets": [ - { - "node": "transform", - "widget": "translate_y" - } - ], - "name": "param5", - "type": "linked_control" - } - ] - } - ], - "parameters": { - "param0": 4, - "param1": 4, - "param2": 3, - "param3": 0.5, - "param4": 0.5, - "param5": 0.5 - }, - "type": "graph" - }, - { - "connections": [ - { - "from": "perlin", - "from_port": 0, - "to": "transform", - "to_port": 1 - }, - { - "from": "transform_2", - "from_port": 0, - "to": "gen_outputs", - "to_port": 0 - }, - { - "from": "perlin", - "from_port": 0, - "to": "transform", - "to_port": 2 - }, - { - "from": "perlin", - "from_port": 0, - "to": "transform_2", - "to_port": 0 - }, - { - "from": "transform", - "from_port": 0, - "to": "transform_2", - "to_port": 1 - }, - { - "from": "transform", - "from_port": 0, - "to": "transform_2", - "to_port": 2 - }, - { - "from": "perlin", - "from_port": 0, - "to": "transform", - "to_port": 0 - } - ], - "label": "Warp2", - "name": "graph_5", - "node_position": { - "x": -214.835205, - "y": 28.599731 - }, - "nodes": [ - { - "name": "transform", - "node_position": { - "x": -292.25, - "y": -629 - }, - "parameters": { - "repeat": false, - "rotate": 0, - "scale_x": 1, - "scale_y": 1, - "translate_x": 0.82, - "translate_y": 0.425 - }, - "type": "transform" - }, - { - "name": "perlin", - "node_position": { - "x": -558.25, - "y": -720 - }, - "parameters": { - "iterations": 5, - "persistence": 0.5, - "scale_x": 4, - "scale_y": 4 - }, - "type": "perlin" - }, - { - "name": "gen_inputs", - "node_position": { - "x": -802.25, - "y": -655.5 - }, - "parameters": { - - }, - "ports": [ - - ], - "type": "ios" - }, - { - "name": "gen_outputs", - "node_position": { - "x": 268.75, - "y": -656.5 - }, - "parameters": { - - }, - "ports": [ - { - "name": "port0", - "type": "rgba" - } - ], - "type": "ios" - }, - { - "name": "gen_parameters", - "node_position": { - "x": -315.75, - "y": -905 - }, - "parameters": { - "param0": 4, - "param1": 0, - "param2": 5, - "param3": 0, - "param4": 0.82, - "param5": 0.425 - }, - "type": "remote", - "widgets": [ - { - "label": "Scale X", - "linked_widgets": [ - { - "node": "perlin", - "widget": "scale_x" - } - ], - "name": "param0", - "type": "linked_control" - }, - { - "label": "Scale Y", - "linked_widgets": [ - { - "node": "perlin", - "widget": "scale_y" - } - ], - "name": "param1", - "type": "linked_control" - }, - { - "label": "Iterations", - "linked_widgets": [ - { - "node": "perlin", - "widget": "iterations" - } - ], - "name": "param2", - "type": "linked_control" - }, - { - "label": "Persistance", - "linked_widgets": [ - { - "node": "perlin", - "widget": "persistence" - } - ], - "name": "param3", - "type": "linked_control" - }, - { - "label": "Warp X", - "linked_widgets": [ - { - "node": "transform", - "widget": "translate_x" - }, - { - "node": "transform_2", - "widget": "translate_x" - } - ], - "name": "param4", - "type": "linked_control" - }, - { - "label": "Warp Y", - "linked_widgets": [ - { - "node": "transform", - "widget": "translate_y" - }, - { - "node": "transform_2", - "widget": "translate_y" - } - ], - "name": "param5", - "type": "linked_control" - } - ] - }, - { - "name": "transform_2", - "node_position": { - "x": -32.462402, - "y": -714.099976 - }, - "parameters": { - "repeat": false, - "rotate": 0, - "scale_x": 1, - "scale_y": 1, - "translate_x": 0.82, - "translate_y": 0.425 - }, - "type": "transform" - } - ], - "parameters": { - "param0": 4, - "param1": 4, - "param2": 5, - "param3": 0.5, - "param4": 0.82, - "param5": 0.425 - }, - "type": "graph" - }, { "name": "bricks", "node_position": { @@ -1413,8 +987,8 @@ { "name": "perlin", "node_position": { - "x": -431.473175, - "y": 305.099731 + "x": -436.473175, + "y": 324.099731 }, "parameters": { "iterations": 3, @@ -1447,6 +1021,1359 @@ "blend_type": 0 }, "type": "blend" + }, + { + "name": "raymarching", + "node_position": { + "x": 242.468536, + "y": 27.145508 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "name": "sdf", + "type": "sdf3d" + } + ], + "instance": "float input_$name(vec3 p) {\n\tif (p.z > 0.0) {\n\t\treturn $sdf(p);\n\t} else {\n\t\treturn p.z;\n\t}\n}\n\nfloat raymarch_$name(vec3 ro, vec3 rd) {\n\tfloat dO=0.; \n for (int i=0; i < 25; i++) {\n \tvec3 p = ro + rd*dO;\n float dS = input_$name(p);\n dO += dS;\n if (dO > 1.0 || dS < 0.0001) break;\n }\n \n return dO;\n}\n\nvec3 normal_$name(vec3 p) {\n\tfloat d = input_$name(p);\n float e = .001;\n \n vec3 n = d - vec3(input_$name(p-vec3(e, 0.0, 0.0)), input_$name(p-vec3(0.0, e, 0.0)), input_$name(p-vec3(0.0, 0.0, e)));\n return vec3(-1.0, -1.0, -1.0)*normalize(n);\n}\n\nvec3 render_$name(vec2 uv) {\n\tvec3 p = vec3(uv, 2.0-raymarch(vec3(uv, 2.0), vec3(0.0, 0.0, -1.0)));\n\tvec3 n = normal(p);\n\tvec3 l = vec3(5.0, 5.0, 10.0);\n\tvec3 ld = normalize(l-p);\n\tfloat o = step(p.z, 0.001);\n\tfloat shadow = 1.0-0.75*step(raymarch(l, -ld), length(l-p)-0.01);\n\tfloat light = 0.3+0.7*dot(n, ld)*shadow;\n\treturnvec3(0.8+0.2*o, 0.8+0.2*o, 1.0)*light;\n}\n", + "name": "Render3d", + "outputs": [ + { + "rgb": "render_$name($uv-vec2(0.5));\n", + "type": "rgb" + } + ], + "parameters": [ + + ] + }, + "type": "shader" + }, + { + "name": "raymarching_2", + "node_position": { + "x": 24.010315, + "y": 37.457581 + }, + "parameters": { + + }, + "type": "raymarching" + }, + { + "name": "raymarching_2_2", + "node_position": { + "x": 26.265625, + "y": 127.457581 + }, + "parameters": { + + }, + "type": "raymarching" + }, + { + "connections": [ + { + "from": "sdf3d_sphere_2", + "from_port": 0, + "to": "sdf3d_translate_4", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3", + "to_port": 1 + }, + { + "from": "sdf3d_smoothboolean_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4_2_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_sphere_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_2", + "to_port": 1 + }, + { + "from": "sdf3d_sphere_2_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4_3_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3_2", + "to_port": 1 + }, + { + "from": "sdf3d_box_2", + "from_port": 0, + "to": "sdf3d_rotate_2", + "to_port": 0 + }, + { + "from": "sdf3d_rotate_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3_2_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3_2_2_2", + "from_port": 0, + "to": "sdf3d_repeat", + "to_port": 0 + }, + { + "from": "sdf3d_rotate_2_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_2_2_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_cylinder", + "from_port": 0, + "to": "sdf3d_translate_4_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3", + "to_port": 0 + }, + { + "from": "sdf3d_sphere_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_3", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_3", + "to_port": 0 + }, + { + "from": "sdf3d_box_2_2", + "from_port": 0, + "to": "sdf3d_rotate_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_box_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_2_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2_3_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2_3_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_3", + "to_port": 0 + }, + { + "from": "sdf3d_sphere_2_3", + "from_port": 0, + "to": "sdf3d_translate_4_3_2_2_2_3", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3_2_2_2_3", + "from_port": 0, + "to": "sdf3d_boolean", + "to_port": 0 + }, + { + "from": "sdf3d_boolean", + "from_port": 0, + "to": "sdf3d_rotate_2_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3_2_2_2_2", + "from_port": 0, + "to": "sdroundedshape", + "to_port": 0 + }, + { + "from": "sdroundedshape", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3_2_2", + "to_port": 1 + }, + { + "from": "sdf3d_repeat", + "from_port": 0, + "to": "sdf3d_rotate_2_2_3", + "to_port": 0 + }, + { + "from": "sdf3d_rotate_2_2_3", + "from_port": 0, + "to": "sdf3d_boolean", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4_3_3", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "sdf3d_scale_2", + "from_port": 0, + "to": "sdf3d_translate_4_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_2", + "from_port": 0, + "to": "sdf3d_scale_2", + "to_port": 0 + } + ], + "label": "Skull", + "name": "graph_3_2", + "node_position": { + "x": -184.234314, + "y": 34.957581 + }, + "nodes": [ + { + "name": "sdf3d_smoothboolean_3", + "node_position": { + "x": -841.989258, + "y": 938.422729 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.04, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_translate_4", + "node_position": { + "x": -1309.989258, + "y": 736.422729 + }, + "parameters": { + "x": 0.52, + "y": -0.22, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_smoothboolean_3_2", + "node_position": { + "x": -629.489258, + "y": 873.422729 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.17, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_sphere_2_2", + "node_position": { + "x": -830.318359, + "y": 1023.672852 + }, + "parameters": { + "r": 0.07 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_translate_4_3", + "node_position": { + "x": -834.318359, + "y": 1078.672852 + }, + "parameters": { + "x": 0.13, + "y": -0.04, + "z": 0.18 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_sphere_2_2_2", + "node_position": { + "x": -831.318359, + "y": 1179.672852 + }, + "parameters": { + "r": 0.08 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_sphere_2", + "node_position": { + "x": -1297.989258, + "y": 844.922729 + }, + "parameters": { + "r": 0.28 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_box_2", + "node_position": { + "x": -855.193726, + "y": 1338.172852 + }, + "parameters": { + "r": 0, + "sx": 0.05, + "sy": 0.05, + "sz": 0.05 + }, + "type": "sdf3d_box" + }, + { + "name": "sdf3d_translate_4_3_2", + "node_position": { + "x": -834.318359, + "y": 1232.672852 + }, + "parameters": { + "x": 0.12, + "y": -0.03, + "z": 0.18 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_rotate_2", + "node_position": { + "x": -839.193726, + "y": 1471.172852 + }, + "parameters": { + "a": 0, + "ax": -30, + "ay": 45, + "az": 0, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 rotate3d(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rotate", + "outputs": [ + { + "sdf3d": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 180, + "min": -180, + "name": "ax", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 180, + "min": -180, + "name": "ay", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Z", + "max": 180, + "min": -180, + "name": "az", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_translate_4_3_2_2", + "node_position": { + "x": -840.193726, + "y": 1600.172852 + }, + "parameters": { + "x": 0, + "y": 0.11, + "z": 0.19 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_smoothboolean_3_2_3", + "node_position": { + "x": -623.818359, + "y": 1236.172852 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.09, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_smoothboolean_3_2_2", + "node_position": { + "x": -622.818359, + "y": 1073.172852 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.15, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_translate_4_2_2", + "node_position": { + "x": -832.989258, + "y": 826.922729 + }, + "parameters": { + "x": 0, + "y": 0.24, + "z": 0.01 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_smoothboolean_3_2_3_2", + "node_position": { + "x": -602.693726, + "y": 1454.672852 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.03, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_translate_4_2", + "node_position": { + "x": -1141.989258, + "y": 1070.922729 + }, + "parameters": { + "x": 0, + "y": 0.21, + "z": 0.08 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_translate_4_3_3", + "node_position": { + "x": -363.318359, + "y": 1762.672852 + }, + "parameters": { + "x": 0.15, + "y": 0, + "z": 0.18 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Mirror", + "outputs": [ + { + "sdf3d": "$in(vec3(abs($uv.x), $uv.y, $uv.z))", + "type": "sdf3d" + } + ], + "parameters": [ + + ] + }, + "type": "shader" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -1375.989258, + "y": 1121.935181 + }, + "parameters": { + + }, + "ports": [ + + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": -179.318359, + "y": 1763.935181 + }, + "parameters": { + + }, + "ports": [ + { + "name": "port0", + "type": "sdf3d" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -1028.995361, + "y": 476.422729 + }, + "parameters": { + + }, + "type": "remote", + "widgets": [ + + ] + }, + { + "name": "sdf3d_translate_4_3_2_2_2", + "node_position": { + "x": -1172.482544, + "y": 1931.119385 + }, + "parameters": { + "x": 0, + "y": 0.14, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Translate", + "outputs": [ + { + "sdf3d": "$in($uv-vec3($x, $y, $z))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 1, + "min": -1, + "name": "x", + "step": 0.01, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 1, + "min": -1, + "name": "y", + "step": 0.01, + "type": "float" + }, + { + "default": 0, + "label": "Z", + "max": 1, + "min": -1, + "name": "z", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_rotate_2_2", + "node_position": { + "x": -1172.482544, + "y": 1829.119385 + }, + "parameters": { + "a": 0, + "ax": 0, + "ay": 0, + "az": 45, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 rotate3d(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rotate", + "outputs": [ + { + "sdf3d": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 180, + "min": -180, + "name": "ax", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 180, + "min": -180, + "name": "ay", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Z", + "max": 180, + "min": -180, + "name": "az", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_repeat", + "node_position": { + "x": -1166.482544, + "y": 2035.119385 + }, + "parameters": { + "a": 0, + "c": 15, + "r": 0.24, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 circle_repeat_transform(vec3 p, float count) {\n\tfloat r = 6.28/count;\n\tfloat pa = atan(p.x, p.y);\n\tfloat a = mod(pa+0.5*r, r)-0.5*r;\n\tvec3 rv;\n\tfloat c = cos(a-pa);\n\tfloat s = sin(a-pa);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Circle Repeat", + "outputs": [ + { + "sdf3d": "$in(circle_repeat_transform($uv, $c))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 4, + "label": "", + "max": 32, + "min": 1, + "name": "c", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_rotate_2_2_2", + "node_position": { + "x": -791.235718, + "y": 1859.869385 + }, + "parameters": { + "a": 0, + "ax": -90, + "ay": 0, + "az": 0, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 rotate3d(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rotate", + "outputs": [ + { + "sdf3d": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 180, + "min": -180, + "name": "ax", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 180, + "min": -180, + "name": "ay", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Z", + "max": 180, + "min": -180, + "name": "az", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_translate_4_3_2_2_2_2", + "node_position": { + "x": -788.235718, + "y": 1967.869385 + }, + "parameters": { + "x": 0, + "y": 0.315, + "z": 0.08 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_cylinder", + "node_position": { + "x": -1161, + "y": 994.5 + }, + "parameters": { + "l": 0.06, + "r": 0.15, + "sx": 0.25, + "sy": 0.25, + "sz": 0.5 + }, + "type": "sdf3d_cylinder" + }, + { + "name": "sdf3d_smoothboolean_3_3", + "node_position": { + "x": -1104.305908, + "y": 815.75 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.1, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_box_2_2", + "node_position": { + "x": -1190.880981, + "y": 1701 + }, + "parameters": { + "r": 0, + "sx": 0.01, + "sy": 0.01, + "sz": 0.015 + }, + "type": "sdf3d_box" + }, + { + "name": "sdf3d_smoothboolean_3_2_3_2_2", + "node_position": { + "x": -562.468933, + "y": 1761.75 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.05, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_sphere_2_3", + "node_position": { + "x": -1165.397095, + "y": 2204.25 + }, + "parameters": { + "r": 0.28 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_translate_4_3_2_2_2_3", + "node_position": { + "x": -1175.397095, + "y": 2261.5 + }, + "parameters": { + "x": 0, + "y": 0.28, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_boolean", + "node_position": { + "x": -990.397095, + "y": 2076 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 2, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "sdroundedshape", + "node_position": { + "x": -794.225342, + "y": 2070.75 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.15, + "op": 0, + "r": 0.01, + "w": 0.28 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rounded", + "outputs": [ + { + "sdf3d": "$in($uv)-$r", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_rotate_2_2_3", + "node_position": { + "x": -1172.268311, + "y": 2085.75 + }, + "parameters": { + "a": 0, + "ax": 0, + "ay": 0, + "az": 11, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 rotate3d(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rotate", + "outputs": [ + { + "sdf3d": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 180, + "min": -180, + "name": "ax", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 180, + "min": -180, + "name": "ay", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Z", + "max": 180, + "min": -180, + "name": "az", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_scale_2", + "node_position": { + "x": -825.646118, + "y": 772.643799 + }, + "parameters": { + "a": 0, + "s": 0.48, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_scale" + } + ], + "parameters": { + + }, + "type": "graph" + }, + { + "connections": [ + { + "from": "sdf3d_box", + "from_port": 0, + "to": "sdf3d_boolean", + "to_port": 1 + }, + { + "from": "sdf3d_box_2", + "from_port": 0, + "to": "sdf3d_translate_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2", + "from_port": 0, + "to": "sdf3d_boolean", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2_2", + "from_port": 0, + "to": "sdf3d_boolean_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean", + "from_port": 0, + "to": "sdf3d_boolean_2", + "to_port": 1 + }, + { + "from": "sdf3d_box_2", + "from_port": 0, + "to": "sdf3d_translate_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean_2", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Brick", + "name": "graph_4", + "node_position": { + "x": -209.947205, + "y": 122.904633 + }, + "nodes": [ + { + "name": "sdf3d_box", + "node_position": { + "x": -564.5, + "y": -63 + }, + "parameters": { + "r": 0.01, + "sx": 0.26, + "sy": 0.15, + "sz": 0.1 + }, + "type": "sdf3d_box" + }, + { + "name": "sdf3d_translate_3_2", + "node_position": { + "x": -554.5, + "y": -166 + }, + "parameters": { + "x": 0, + "y": 0, + "z": 0.45 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_box_2", + "node_position": { + "x": -570.5, + "y": -294.5 + }, + "parameters": { + "r": 0, + "sx": 0.21, + "sy": 0.1, + "sz": 0.36 + }, + "type": "sdf3d_box" + }, + { + "name": "sdf3d_boolean", + "node_position": { + "x": -358.5, + "y": -118 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "sdf3d_translate_3_2_2", + "node_position": { + "x": -343.333344, + "y": -224.333344 + }, + "parameters": { + "x": 0, + "y": 0, + "z": -0.45 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_boolean_2", + "node_position": { + "x": -147.333344, + "y": -168.333344 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -748.5, + "y": -159.361115 + }, + "parameters": { + + }, + "ports": [ + + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 60.666656, + "y": -165.361115 + }, + "parameters": { + + }, + "ports": [ + { + "name": "port0", + "type": "sdf3d" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -488.111115, + "y": -466.5 + }, + "parameters": { + + }, + "type": "remote", + "widgets": [ + + ] + } + ], + "parameters": { + + }, + "type": "graph" + }, + { + "name": "sdf3d_rotate_2", + "node_position": { + "x": -241.447205, + "y": 169.404633 + }, + "parameters": { + "a": 0, + "ax": 25, + "ay": 23, + "az": -8, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_rotate" + }, + { + "name": "sdf3d_translate_3_2", + "node_position": { + "x": -233.447205, + "y": 270.404633 + }, + "parameters": { + "x": 0, + "y": 0, + "z": 0.25 + }, + "type": "sdf3d_translate" } ], "parameters": { diff --git a/addons/material_maker/examples/pile_of_bricks.ptex b/addons/material_maker/examples/pile_of_bricks.ptex new file mode 100644 index 0000000..d28e5eb --- /dev/null +++ b/addons/material_maker/examples/pile_of_bricks.ptex @@ -0,0 +1,625 @@ +{ + "connections": [ + { + "from": "uniform", + "from_port": 0, + "to": "Material", + "to_port": 0 + }, + { + "from": "graph", + "from_port": 0, + "to": "sdf3d_scale_2", + "to_port": 0 + }, + { + "from": "sdf3d_scale_2", + "from_port": 0, + "to": "sdf3d_repeat", + "to_port": 0 + }, + { + "from": "sdf3d_repeat", + "from_port": 0, + "to": "sdf3d_boolean_3", + "to_port": 0 + }, + { + "from": "sdf3d_scale_2", + "from_port": 0, + "to": "sdf3d_repeat_2", + "to_port": 0 + }, + { + "from": "sdf3d_repeat_2", + "from_port": 0, + "to": "sdf3d_translate_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2", + "from_port": 0, + "to": "sdf3d_boolean_3", + "to_port": 1 + }, + { + "from": "sdf3d_repeat_3", + "from_port": 0, + "to": "sdf3d_boolean_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_repeat_2_2", + "from_port": 0, + "to": "sdf3d_translate_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2_2", + "from_port": 0, + "to": "sdf3d_boolean_3_2", + "to_port": 1 + }, + { + "from": "sdf3d_scale_2", + "from_port": 0, + "to": "sdf3d_repeat_3", + "to_port": 0 + }, + { + "from": "sdf3d_scale_2", + "from_port": 0, + "to": "sdf3d_repeat_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean_3_2", + "from_port": 0, + "to": "sdf3d_boolean_3_3", + "to_port": 1 + }, + { + "from": "sdf3d_boolean_3_3", + "from_port": 0, + "to": "sdf3d_translate_3_2_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean_3", + "from_port": 0, + "to": "sdf3d_translate_3_2_3", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2_3", + "from_port": 0, + "to": "sdf3d_boolean_3_3", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2_2_2", + "from_port": 0, + "to": "raymarching", + "to_port": 0 + }, + { + "from": "raymarching", + "from_port": 1, + "to": "Material", + "to_port": 4 + }, + { + "from": "occlusion", + "from_port": 0, + "to": "Material", + "to_port": 5 + }, + { + "from": "raymarching", + "from_port": 0, + "to": "occlusion", + "to_port": 0 + }, + { + "from": "raymarching", + "from_port": 0, + "to": "colorize", + "to_port": 0 + }, + { + "from": "colorize", + "from_port": 0, + "to": "Material", + "to_port": 6 + } + ], + "label": "Graph", + "name": "49", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "Material", + "node_position": { + "x": 701, + "y": 78 + }, + "parameters": { + "albedo_color": { + "a": 1, + "b": 1, + "g": 1, + "r": 1, + "type": "Color" + }, + "ao_light_affect": 1, + "depth_scale": 0.5, + "emission_energy": 1, + "metallic": 1, + "normal_scale": 1, + "roughness": 1, + "size": 11, + "subsurf_scatter_strength": 0 + }, + "type": "material" + }, + { + "name": "uniform", + "node_position": { + "x": 467.5, + "y": 84 + }, + "parameters": { + "color": { + "a": 1, + "b": 0.180392, + "g": 0.372549, + "r": 0.768627, + "type": "Color" + } + }, + "type": "uniform" + }, + { + "name": "sdf3d_repeat", + "node_position": { + "x": -224.214783, + "y": -156 + }, + "parameters": { + "a": 0, + "r": 0.3, + "rx": 6, + "ry": 6, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_repeat" + }, + { + "name": "sdf3d_scale_2", + "node_position": { + "x": -422.214783, + "y": 72 + }, + "parameters": { + "a": 0, + "s": 0.25, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_scale" + }, + { + "name": "sdf3d_boolean_3", + "node_position": { + "x": -16.214783, + "y": -56 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "connections": [ + { + "from": "sdf3d_box", + "from_port": 0, + "to": "sdf3d_boolean", + "to_port": 1 + }, + { + "from": "sdf3d_box_2", + "from_port": 0, + "to": "sdf3d_translate_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2", + "from_port": 0, + "to": "sdf3d_boolean", + "to_port": 0 + }, + { + "from": "sdf3d_translate_3_2_2", + "from_port": 0, + "to": "sdf3d_boolean_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean", + "from_port": 0, + "to": "sdf3d_boolean_2", + "to_port": 1 + }, + { + "from": "sdf3d_box_2", + "from_port": 0, + "to": "sdf3d_translate_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean_2", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Brick", + "name": "graph", + "node_position": { + "x": -427.111115, + "y": 2.638885 + }, + "nodes": [ + { + "name": "sdf3d_box", + "node_position": { + "x": -564.5, + "y": -63 + }, + "parameters": { + "r": 0.01, + "sx": 0.26, + "sy": 0.15, + "sz": 0.1 + }, + "type": "sdf3d_box" + }, + { + "name": "sdf3d_translate_3_2", + "node_position": { + "x": -554.5, + "y": -166 + }, + "parameters": { + "x": 0, + "y": 0, + "z": 0.45 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_box_2", + "node_position": { + "x": -570.5, + "y": -294.5 + }, + "parameters": { + "r": 0, + "sx": 0.21, + "sy": 0.1, + "sz": 0.36 + }, + "type": "sdf3d_box" + }, + { + "name": "sdf3d_boolean", + "node_position": { + "x": -358.5, + "y": -118 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "sdf3d_translate_3_2_2", + "node_position": { + "x": -343.333344, + "y": -224.333344 + }, + "parameters": { + "x": 0, + "y": 0, + "z": -0.45 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_boolean_2", + "node_position": { + "x": -147.333344, + "y": -168.333344 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -748.5, + "y": -159.361115 + }, + "parameters": { + + }, + "ports": [ + + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 60.666656, + "y": -165.361115 + }, + "parameters": { + + }, + "ports": [ + { + "name": "port0", + "type": "sdf3d" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -488.111115, + "y": -466.5 + }, + "parameters": { + + }, + "type": "remote", + "widgets": [ + + ] + } + ], + "parameters": { + + }, + "type": "graph" + }, + { + "name": "sdf3d_repeat_2", + "node_position": { + "x": -225.542572, + "y": -52.060181 + }, + "parameters": { + "a": 0, + "r": 0.3, + "rx": 6, + "ry": 6, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_repeat" + }, + { + "name": "sdf3d_translate_3_2", + "node_position": { + "x": -224.542572, + "y": 49.939819 + }, + "parameters": { + "x": 0.09, + "y": 0.09, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_repeat_2_2", + "node_position": { + "x": -220.331467, + "y": 259.034729 + }, + "parameters": { + "a": 0, + "r": 0.3, + "rx": 6, + "ry": 6, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_repeat" + }, + { + "name": "sdf3d_repeat_3", + "node_position": { + "x": -219.003677, + "y": 155.09491 + }, + "parameters": { + "a": 0, + "r": 0.3, + "rx": 6, + "ry": 6, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_repeat" + }, + { + "name": "sdf3d_translate_3_2_2", + "node_position": { + "x": -219.331467, + "y": 361.034729 + }, + "parameters": { + "x": 0.09, + "y": 0.09, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_boolean_3_2", + "node_position": { + "x": -19.003677, + "y": 251.09491 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "sdf3d_boolean_3_3", + "node_position": { + "x": 183.957428, + "y": 120.689819 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "sdf3d_translate_3_2_2_2", + "node_position": { + "x": 179.457428, + "y": 193.189819 + }, + "parameters": { + "x": 0, + "y": 0, + "z": 0.3 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_translate_3_2_3", + "node_position": { + "x": -19.542572, + "y": 10.189819 + }, + "parameters": { + "x": 0.04, + "y": 0.04, + "z": 0.15 + }, + "type": "sdf3d_translate" + }, + { + "name": "raymarching", + "node_position": { + "x": 187.457397, + "y": 303.189819 + }, + "parameters": { + + }, + "type": "raymarching" + }, + { + "name": "occlusion", + "node_position": { + "x": 410.234558, + "y": 303.189819 + }, + "parameters": { + "param0": 9, + "param1": 50, + "param2": 5.2 + }, + "type": "occlusion" + }, + { + "name": "colorize", + "node_position": { + "x": 430.387573, + "y": 218.189819 + }, + "parameters": { + "gradient": { + "interpolation": 1, + "points": [ + { + "a": 1, + "b": 1, + "g": 1, + "pos": 0, + "r": 1 + }, + { + "a": 1, + "b": 0, + "g": 0, + "pos": 0.563636, + "r": 0 + } + ], + "type": "Gradient" + } + }, + "type": "colorize" + } + ], + "parameters": { + + }, + "type": "graph" +} \ No newline at end of file diff --git a/addons/material_maker/examples/raymarching.ptex b/addons/material_maker/examples/raymarching.ptex new file mode 100644 index 0000000..4d20255 --- /dev/null +++ b/addons/material_maker/examples/raymarching.ptex @@ -0,0 +1,389 @@ +{ + "connections": [ + { + "from": "sdbox", + "from_port": 0, + "to": "sdboolean", + "to_port": 1 + }, + { + "from": "sdrhombus_2", + "from_port": 0, + "to": "sdboolean", + "to_port": 0 + }, + { + "from": "sdboolean", + "from_port": 0, + "to": "_4_2_3", + "to_port": 0 + }, + { + "from": "_4_2_3", + "from_port": 0, + "to": "sdf3d_revolution", + "to_port": 0 + }, + { + "from": "sdf3d_revolution", + "from_port": 0, + "to": "sdrotate", + "to_port": 0 + }, + { + "from": "raymarching", + "from_port": 1, + "to": "Material", + "to_port": 4 + }, + { + "from": "sdrotate", + "from_port": 0, + "to": "raymarching", + "to_port": 0 + }, + { + "from": "uniform", + "from_port": 0, + "to": "Material", + "to_port": 0 + }, + { + "from": "uniform", + "from_port": 0, + "to": "Material", + "to_port": 1 + } + ], + "label": "Graph", + "name": "49", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "Material", + "node_position": { + "x": -336, + "y": 266 + }, + "parameters": { + "albedo_color": { + "a": 1, + "b": 1, + "g": 1, + "r": 1, + "type": "Color" + }, + "ao_light_affect": 1, + "depth_scale": 1, + "emission_energy": 1, + "metallic": 1, + "normal_scale": 1, + "roughness": 1, + "size": 11, + "subsurf_scatter_strength": 0 + }, + "type": "material" + }, + { + "name": "sdrotate", + "node_position": { + "x": -722.057617, + "y": 347.909668 + }, + "parameters": { + "a": 0, + "ax": 18, + "ay": -28, + "az": -29, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 rotate3d(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rotate", + "outputs": [ + { + "sdf3d": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 180, + "min": -180, + "name": "ax", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 180, + "min": -180, + "name": "ay", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Z", + "max": 180, + "min": -180, + "name": "az", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdrhombus_2", + "node_position": { + "x": -1116.057617, + "y": 261.159668 + }, + "parameters": { + "cx": 0, + "cy": 0, + "h": 0.29, + "r": 0.3, + "w": 0.3 + }, + "type": "sdrhombus" + }, + { + "name": "sdbox", + "node_position": { + "x": -1119.057617, + "y": 401.159668 + }, + "parameters": { + "cx": 0, + "cy": 0, + "h": 0.2, + "r": 0.3, + "w": 0.2 + }, + "shader_model": { + "code": "vec2 $(name_uv)_d = abs($uv-0.5*vec2($cx+1.0, $cy+1.0))-vec2($w, $h);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "sdBox", + "outputs": [ + { + "sdf2d": "length(max($(name_uv)_d,vec2(0)))+min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0)", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": 0.5, + "label": "Width", + "max": 1, + "min": 0, + "name": "w", + "step": 0.01, + "type": "float" + }, + { + "default": 1, + "label": "Height", + "max": 1, + "min": 0, + "name": "h", + "step": 0.01, + "type": "float" + }, + { + "default": 0, + "label": "Center X", + "max": 1, + "min": -1, + "name": "cx", + "step": 0.01, + "type": "float" + }, + { + "default": 0, + "label": "Center Y", + "max": 1, + "min": -1, + "name": "cy", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdboolean", + "node_position": { + "x": -894.057617, + "y": 297.159668 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdboolean" + }, + { + "name": "_4_2_3", + "node_position": { + "x": -903.047241, + "y": 363.697357 + }, + "parameters": { + "x": 0, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Translate", + "outputs": [ + { + "sdf2d": "$in($uv-vec2($x, $y))", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 1, + "min": -1, + "name": "x", + "step": 0.01, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 1, + "min": -1, + "name": "y", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_revolution", + "node_position": { + "x": -714.403931, + "y": 295.330994 + }, + "parameters": { + "a": 0, + "d": 0.43, + "s": 1, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "vec2 $(name_uv)_w = vec2($in($uv.xz+vec2(0.5)),abs($uv.y)-$d);\n", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Extrusion", + "outputs": [ + { + "sdf3d": "min(max($(name_uv)_w.x,$(name_uv)_w.y),0.0)+length(max($(name_uv)_w,0.0))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.25, + "label": "", + "max": 1, + "min": 0, + "name": "d", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "raymarching", + "node_position": { + "x": -522.23468, + "y": 348.748474 + }, + "parameters": { + + }, + "type": "raymarching" + }, + { + "name": "uniform", + "node_position": { + "x": -576.760742, + "y": 211.755493 + }, + "parameters": { + "color": { + "a": 1, + "b": 1, + "g": 0.415686, + "r": 0, + "type": "Color" + } + }, + "type": "uniform" + } + ], + "parameters": { + + }, + "type": "graph" +} \ No newline at end of file diff --git a/addons/material_maker/examples/skulls.ptex b/addons/material_maker/examples/skulls.ptex new file mode 100644 index 0000000..9e92938 --- /dev/null +++ b/addons/material_maker/examples/skulls.ptex @@ -0,0 +1,2016 @@ +{ + "connections": [ + { + "from": "perlin", + "from_port": 0, + "to": "colorize", + "to_port": 0 + }, + { + "from": "perlin", + "from_port": 0, + "to": "colorize_2", + "to_port": 0 + }, + { + "from": "uniform_greyscale", + "from_port": 0, + "to": "Material", + "to_port": 1 + }, + { + "from": "colorize_3", + "from_port": 0, + "to": "Material", + "to_port": 6 + }, + { + "from": "occlusion", + "from_port": 0, + "to": "Material", + "to_port": 5 + }, + { + "from": "sdf3d_scale", + "from_port": 0, + "to": "sdf3d_scale_2", + "to_port": 0 + }, + { + "from": "sdf3d_scale_2", + "from_port": 0, + "to": "sdf3d_boolean_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4", + "from_port": 0, + "to": "sdf3d_boolean_2", + "to_port": 1 + }, + { + "from": "sdf3d_scale", + "from_port": 0, + "to": "sdf3d_repeat", + "to_port": 0 + }, + { + "from": "sdf3d_repeat", + "from_port": 0, + "to": "sdf3d_translate_4", + "to_port": 0 + }, + { + "from": "perlin", + "from_port": 0, + "to": "colorize_4", + "to_port": 0 + }, + { + "from": "colorize_2", + "from_port": 0, + "to": "blend", + "to_port": 0 + }, + { + "from": "colorize_4", + "from_port": 0, + "to": "blend", + "to_port": 1 + }, + { + "from": "blend", + "from_port": 0, + "to": "Material", + "to_port": 0 + }, + { + "from": "graph_2", + "from_port": 0, + "to": "sdf3d_scale_3", + "to_port": 0 + }, + { + "from": "sdf3d_scale_3", + "from_port": 0, + "to": "sdf3d_repeat_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean_2", + "from_port": 0, + "to": "sdf3d_boolean_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_repeat_2", + "from_port": 0, + "to": "sdf3d_translate_4_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_2", + "from_port": 0, + "to": "sdf3d_boolean_2_2", + "to_port": 1 + }, + { + "from": "sdf3d_repeat_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_scale_3", + "from_port": 0, + "to": "sdf3d_repeat_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean_2_2", + "from_port": 0, + "to": "sdf3d_boolean_2_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_2_2", + "from_port": 0, + "to": "sdf3d_boolean_2_2_2", + "to_port": 1 + }, + { + "from": "sdf3d_boolean_2_2_2", + "from_port": 0, + "to": "_3_2", + "to_port": 0 + }, + { + "from": "blend_2", + "from_port": 0, + "to": "Material", + "to_port": 4 + }, + { + "from": "perlin", + "from_port": 0, + "to": "normal_map", + "to_port": 0 + }, + { + "from": "_3_2", + "from_port": 1, + "to": "blend_2", + "to_port": 0 + }, + { + "from": "normal_map", + "from_port": 0, + "to": "blend_2", + "to_port": 1 + }, + { + "from": "colorize_5_2", + "from_port": 0, + "to": "blend_2", + "to_port": 2 + }, + { + "from": "graph_3", + "from_port": 0, + "to": "sdf3d_scale", + "to_port": 0 + }, + { + "from": "_3_2", + "from_port": 0, + "to": "buffer", + "to_port": 0 + }, + { + "from": "buffer", + "from_port": 0, + "to": "colorize_5", + "to_port": 0 + }, + { + "from": "buffer", + "from_port": 0, + "to": "colorize_5_2", + "to_port": 0 + }, + { + "from": "buffer", + "from_port": 0, + "to": "occlusion", + "to_port": 0 + }, + { + "from": "buffer", + "from_port": 0, + "to": "colorize_3", + "to_port": 0 + }, + { + "from": "colorize", + "from_port": 0, + "to": "blend_3", + "to_port": 0 + }, + { + "from": "blend_3", + "from_port": 0, + "to": "Material", + "to_port": 2 + }, + { + "from": "colorize_5", + "from_port": 0, + "to": "blend_3", + "to_port": 1 + }, + { + "from": "colorize_5_2", + "from_port": 0, + "to": "blend", + "to_port": 2 + } + ], + "label": "Graph", + "name": "49", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "Material", + "node_position": { + "x": 390, + "y": 1354 + }, + "parameters": { + "albedo_color": { + "a": 1, + "b": 1, + "g": 1, + "r": 1, + "type": "Color" + }, + "ao_light_affect": 1, + "depth_scale": 1, + "emission_energy": 1, + "metallic": 1, + "normal_scale": 1, + "roughness": 1, + "size": 11, + "subsurf_scatter_strength": 0 + }, + "type": "material" + }, + { + "name": "perlin", + "node_position": { + "x": -385.399658, + "y": 1196.349854 + }, + "parameters": { + "iterations": 5, + "persistence": 0.7, + "scale_x": 32, + "scale_y": 32 + }, + "type": "perlin" + }, + { + "name": "colorize", + "node_position": { + "x": -347.399658, + "y": 1342.349976 + }, + "parameters": { + "gradient": { + "interpolation": 1, + "points": [ + { + "a": 1, + "b": 0, + "g": 0, + "pos": 0.118182, + "r": 0 + }, + { + "a": 1, + "b": 1, + "g": 1, + "pos": 0.909091, + "r": 1 + } + ], + "type": "Gradient" + } + }, + "type": "colorize" + }, + { + "name": "_3_2", + "node_position": { + "x": -378.336426, + "y": 1476.947388 + }, + "parameters": { + + }, + "shader_model": { + "code": "float $(name_uv)_d = raymarch_$name($uv);\n", + "global": "", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "name": "sdf", + "type": "sdf3d" + } + ], + "instance": "float input_$name(vec3 p) {\n\treturn min($sdf(p), p.z);\n}\n\nfloat raymarch_$name(vec2 uv) {\n\tvec3 ro = vec3(uv-vec2(0.5), 1.0);\n\tvec3 rd = vec3(0.0, 0.0, -1.0);\n\tfloat dO=0.;\n \n for (int i=0; i < 50; i++) {\n \tvec3 p = ro + rd*dO;\n float dS = input_$name(p);\n dO += dS;\n if (dO > 0.001 && dS < 0.0001) break;\n }\n \n return dO;\n}\n\nvec3 normal_$name(vec3 p) {\n\tfloat d = input_$name(p);\n float e = .001;\n \n vec3 n = d - vec3(\n input_$name(p-vec3(e, 0.0, 0.0)),\n input_$name(p-vec3(0.0, e, 0.0)),\n input_$name(p-vec3(0.0, 0.0, e)));\n \n return vec3(-1.0, -1.0, -1.0)*normalize(n);\n}\n\n", + "name": "Raymarching", + "outputs": [ + { + "f": "1.0-$(name_uv)_d", + "type": "f" + }, + { + "rgb": "vec3(0.5)+0.5*normal_$name(vec3($uv-vec2(0.5), 1.0-$(name_uv)_d))", + "type": "rgb" + } + ], + "parameters": [ + + ] + }, + "type": "shader" + }, + { + "name": "colorize_2", + "node_position": { + "x": -126.553131, + "y": 1179.272949 + }, + "parameters": { + "gradient": { + "interpolation": 1, + "points": [ + { + "a": 1, + "b": 0.994792, + "g": 0.999512, + "pos": 0, + "r": 1 + }, + { + "a": 1, + "b": 0.885417, + "g": 0.989258, + "pos": 1, + "r": 1 + } + ], + "type": "Gradient" + } + }, + "type": "colorize" + }, + { + "name": "uniform_greyscale", + "node_position": { + "x": 138.446899, + "y": 1239.272949 + }, + "parameters": { + "color": 0.31 + }, + "type": "uniform_greyscale" + }, + { + "name": "colorize_3", + "node_position": { + "x": 38.446899, + "y": 1686.272949 + }, + "parameters": { + "gradient": { + "interpolation": 1, + "points": [ + { + "a": 1, + "b": 1, + "g": 1, + "pos": 0, + "r": 1 + }, + { + "a": 1, + "b": 0, + "g": 0, + "pos": 0.663637, + "r": 0 + } + ], + "type": "Gradient" + } + }, + "type": "colorize" + }, + { + "name": "sdf3d_scale", + "node_position": { + "x": -994.911377, + "y": 1248.772949 + }, + "parameters": { + "a": 0, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_scale" + }, + { + "name": "sdf3d_scale_2", + "node_position": { + "x": -811.183411, + "y": 1198.851807 + }, + "parameters": { + "a": 0, + "r": 0.25, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 repeat(vec3 p, vec3 r, float seed, float randomness) {\n\tvec3 a = (rand3(floor(mod((p.xy+0.5*r.xy)/r.xy, 1.0/r.xy)+vec2(seed)))-0.5)*6.28*randomness;\n\tp = mod(p+0.5*r,r)-0.5*r;\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Repeat", + "outputs": [ + { + "sdf3d": "$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), $seed, $r))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 4, + "label": "X", + "max": 32, + "min": 1, + "name": "rx", + "step": 1, + "type": "float" + }, + { + "default": 4, + "label": "Y", + "max": 32, + "min": 1, + "name": "ry", + "step": 1, + "type": "float" + }, + { + "default": 0.5, + "label": "R", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "occlusion", + "node_position": { + "x": 12.088623, + "y": 1608.272949 + }, + "parameters": { + "param0": 10, + "param1": 50, + "param2": 15 + }, + "type": "occlusion" + }, + { + "name": "sdf3d_translate_4", + "node_position": { + "x": -813.195313, + "y": 1400.797363 + }, + "parameters": { + "x": 0.4, + "y": 0.35, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_boolean_2", + "node_position": { + "x": -622.79303, + "y": 1304.297363 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "sdf3d_repeat", + "node_position": { + "x": -812.79303, + "y": 1300.297363 + }, + "parameters": { + "a": 0, + "r": 0.25, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_repeat" + }, + { + "name": "colorize_4", + "node_position": { + "x": -128.79303, + "y": 1246.013184 + }, + "parameters": { + "gradient": { + "interpolation": 1, + "points": [ + { + "a": 1, + "b": 0, + "g": 0.300774, + "pos": 0, + "r": 0.458333 + }, + { + "a": 1, + "b": 0, + "g": 0.046875, + "pos": 1, + "r": 0.1875 + } + ], + "type": "Gradient" + } + }, + "type": "colorize" + }, + { + "name": "colorize_5", + "node_position": { + "x": -147.127869, + "y": 1324.013184 + }, + "parameters": { + "gradient": { + "interpolation": 0, + "points": [ + { + "a": 1, + "b": 1, + "g": 1, + "pos": 0, + "r": 1 + }, + { + "a": 1, + "b": 0.520833, + "g": 0.520833, + "pos": 0.036364, + "r": 0.520833 + } + ], + "type": "Gradient" + } + }, + "type": "colorize" + }, + { + "name": "blend", + "node_position": { + "x": 126.872131, + "y": 1141.013184 + }, + "parameters": { + "amount": 0.5, + "blend_type": 0 + }, + "type": "blend" + }, + { + "name": "sdf3d_repeat_2", + "node_position": { + "x": -931.880676, + "y": 1576.431152 + }, + "parameters": { + "a": 0, + "r": 0.46, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_repeat" + }, + { + "connections": [ + { + "from": "sdf3d_sphere_2", + "from_port": 0, + "to": "sdf3d_translate_4_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_sphere_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_2_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3", + "to_port": 1 + }, + { + "from": "sdf3d_smoothboolean_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_sphere_2_2_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2", + "to_port": 1 + }, + { + "from": "sdf3d_sphere_2_2_3", + "from_port": 0, + "to": "sdf3d_translate_4_2_3", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2", + "from_port": 0, + "to": "sdf3d_boolean_2_2", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4_2_3", + "from_port": 0, + "to": "sdf3d_boolean_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_boolean_2_2", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Bone", + "name": "graph_2", + "node_position": { + "x": -1109.480713, + "y": 1577.556274 + }, + "nodes": [ + { + "name": "sdf3d_translate_4_2_2", + "node_position": { + "x": -935.880676, + "y": 1383.431152 + }, + "parameters": { + "x": -0.03, + "y": -0.22, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_sphere_2", + "node_position": { + "x": -930.880676, + "y": 1327.931152 + }, + "parameters": { + "r": 0.03 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_sphere_2_2_2", + "node_position": { + "x": -937.880676, + "y": 1638.431152 + }, + "parameters": { + "h": 0.4, + "r": 0.025 + }, + "shader_model": { + "code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.y -= clamp($(name_uv)_p.y, -0.5*$h, 0.5*$h);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Sphere", + "outputs": [ + { + "sdf3d": "length($(name_uv)_p)-$r", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.5, + "label": "H", + "max": 1, + "min": 0, + "name": "h", + "step": 0.01, + "type": "float" + }, + { + "default": 0.1, + "label": "R", + "max": 0.5, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_smoothboolean_3_2", + "node_position": { + "x": -744.380676, + "y": 1604.931152 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.02, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_smoothboolean_3", + "node_position": { + "x": -744.880676, + "y": 1527.931152 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.01, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "shader_model": { + "code": "", + "global": "float sdf3SmoothUnion(float d1, float d2, float k) {\n float h = clamp(0.5+0.5*(d2-d1)/k, 0.0, 1.0);\n return mix(d2, d1, h)-k*h*(1.0-h);\n}\n\nfloat sdf3SmoothSubtraction( float d1, float d2, float k ) {\n float h = clamp(0.5-0.5*(d2+d1)/k, 0.0, 1.0);\n return mix( d2, -d1, h )+k*h*(1.0-h);\n}\n\nfloat sdf3SmoothIntersection( float d1, float d2, float k ) {\n float h = clamp(0.5-0.5*(d2-d1)/k, 0.0, 1.0);\n return mix(d2, d1, h)+k*h*(1.0-h);\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in1", + "type": "sdf3d" + }, + { + "default": "0.0", + "label": "", + "name": "in2", + "type": "sdf3d" + } + ], + "instance": "", + "name": "sdSmoothBoolean", + "outputs": [ + { + "sdf3d": "sdf3Smooth$op($in1($uv), $in2($uv), $k)", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "name": "op", + "type": "enum", + "values": [ + { + "name": "Union", + "value": "Union" + }, + { + "name": "Subtraction", + "value": "Subtraction" + }, + { + "name": "Intersection", + "value": "Intersection" + } + ] + }, + { + "default": 0, + "label": "", + "max": 1, + "min": 0, + "name": "k", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_sphere_2_2", + "node_position": { + "x": -929.880676, + "y": 1483.431152 + }, + "parameters": { + "r": 0.04 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_translate_4_2", + "node_position": { + "x": -934.880676, + "y": 1534.431152 + }, + "parameters": { + "x": 0.02, + "y": -0.25, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_translate_4_2_3", + "node_position": { + "x": -936.380676, + "y": 1792.181152 + }, + "parameters": { + "x": -0.04, + "y": 0.21, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_sphere_2_2_3", + "node_position": { + "x": -931.380676, + "y": 1741.181152 + }, + "parameters": { + "r": 0.06 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_boolean_2_2", + "node_position": { + "x": -747.380676, + "y": 1680.681152 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -1237.880615, + "y": 1568.556274 + }, + "parameters": { + + }, + "ports": [ + + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": -447.380676, + "y": 1568.556274 + }, + "parameters": { + + }, + "ports": [ + { + "name": "port0", + "type": "sdf3d" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -1079.480713, + "y": 1027.931152 + }, + "parameters": { + + }, + "type": "remote", + "widgets": [ + + ] + } + ], + "parameters": { + + }, + "type": "graph" + }, + { + "name": "sdf3d_scale_3", + "node_position": { + "x": -1130.764893, + "y": 1621.628418 + }, + "parameters": { + "a": 0, + "s": 0.4, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_scale" + }, + { + "name": "sdf3d_boolean_2_2", + "node_position": { + "x": -546.264893, + "y": 1515.128418 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "sdf3d_translate_4_2", + "node_position": { + "x": -753.844666, + "y": 1576.628418 + }, + "parameters": { + "x": 0.35, + "y": 0.52, + "z": 0.02 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_repeat_2_2", + "node_position": { + "x": -936.362671, + "y": 1681.529785 + }, + "parameters": { + "a": 0, + "r": 0.5, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_repeat" + }, + { + "name": "sdf3d_translate_4_2_2", + "node_position": { + "x": -753.32666, + "y": 1681.727051 + }, + "parameters": { + "x": 0.51, + "y": 0.38, + "z": 0.02 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_boolean_2_2_2", + "node_position": { + "x": -546.344666, + "y": 1580.128418 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "normal_map", + "node_position": { + "x": 52.85556, + "y": 1392.238892 + }, + "parameters": { + "amount": 0.5, + "param0": 11, + "param1": 1.02, + "param2": 0, + "size": 4 + }, + "type": "normal_map" + }, + { + "name": "blend_2", + "node_position": { + "x": 23.85556, + "y": 1485.238892 + }, + "parameters": { + "amount": 1, + "blend_type": 0 + }, + "type": "blend" + }, + { + "name": "colorize_5_2", + "node_position": { + "x": -190.144485, + "y": 1443.488892 + }, + "parameters": { + "gradient": { + "interpolation": 0, + "points": [ + { + "a": 1, + "b": 0, + "g": 0, + "pos": 0, + "r": 0 + }, + { + "a": 1, + "b": 1, + "g": 1, + "pos": 0.027272, + "r": 1 + } + ], + "type": "Gradient" + } + }, + "type": "colorize" + }, + { + "connections": [ + { + "from": "sdf3d_sphere_2", + "from_port": 0, + "to": "sdf3d_translate_4", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3", + "to_port": 1 + }, + { + "from": "sdf3d_scale", + "from_port": 0, + "to": "sdf3d_translate_4_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4_2_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_sphere_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_2", + "to_port": 1 + }, + { + "from": "sdf3d_sphere_2_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4_3_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3_2", + "to_port": 1 + }, + { + "from": "sdf3d_box_2", + "from_port": 0, + "to": "sdf3d_rotate_2", + "to_port": 0 + }, + { + "from": "sdf3d_rotate_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3_2_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3_2_2_2", + "from_port": 0, + "to": "sdf3d_repeat", + "to_port": 0 + }, + { + "from": "sdf3d_rotate_2_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_2_2_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_cylinder", + "from_port": 0, + "to": "sdf3d_translate_4_2", + "to_port": 0 + }, + { + "from": "sdf3d_cylinder", + "from_port": 0, + "to": "sdf3d_scale", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_3", + "from_port": 0, + "to": "sdf3d_smoothboolean_3", + "to_port": 0 + }, + { + "from": "sdf3d_sphere_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_3", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_3", + "to_port": 0 + }, + { + "from": "sdf3d_box_2_2", + "from_port": 0, + "to": "sdf3d_rotate_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_box_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_2_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2_3_2", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_smoothboolean_3_2_3_2_2", + "from_port": 0, + "to": "sdf3d_translate_4_3_3", + "to_port": 0 + }, + { + "from": "sdf3d_sphere_2_3", + "from_port": 0, + "to": "sdf3d_translate_4_3_2_2_2_3", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3_2_2_2_3", + "from_port": 0, + "to": "sdf3d_boolean", + "to_port": 0 + }, + { + "from": "sdf3d_boolean", + "from_port": 0, + "to": "sdf3d_rotate_2_2_2", + "to_port": 0 + }, + { + "from": "sdf3d_translate_4_3_2_2_2_2", + "from_port": 0, + "to": "sdroundedshape", + "to_port": 0 + }, + { + "from": "sdroundedshape", + "from_port": 0, + "to": "sdf3d_smoothboolean_3_2_3_2_2", + "to_port": 1 + }, + { + "from": "sdf3d_repeat", + "from_port": 0, + "to": "sdf3d_rotate_2_2_3", + "to_port": 0 + }, + { + "from": "sdf3d_rotate_2_2_3", + "from_port": 0, + "to": "sdf3d_boolean", + "to_port": 1 + }, + { + "from": "sdf3d_translate_4_3_3", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Skull", + "name": "graph_3", + "node_position": { + "x": -960.932495, + "y": 1204.712646 + }, + "nodes": [ + { + "name": "sdf3d_smoothboolean_3", + "node_position": { + "x": -841.989258, + "y": 938.422729 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.04, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_translate_4", + "node_position": { + "x": -1309.989258, + "y": 736.422729 + }, + "parameters": { + "x": 0.52, + "y": -0.22, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_smoothboolean_3_2", + "node_position": { + "x": -629.489258, + "y": 873.422729 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.17, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_sphere_2_2", + "node_position": { + "x": -830.318359, + "y": 1023.672852 + }, + "parameters": { + "r": 0.07 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_translate_4_3", + "node_position": { + "x": -834.318359, + "y": 1078.672852 + }, + "parameters": { + "x": 0.13, + "y": -0.04, + "z": 0.18 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_sphere_2_2_2", + "node_position": { + "x": -831.318359, + "y": 1179.672852 + }, + "parameters": { + "r": 0.08 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_sphere_2", + "node_position": { + "x": -1297.989258, + "y": 844.922729 + }, + "parameters": { + "r": 0.28 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_box_2", + "node_position": { + "x": -855.193726, + "y": 1338.172852 + }, + "parameters": { + "r": 0, + "sx": 0.05, + "sy": 0.05, + "sz": 0.05 + }, + "type": "sdf3d_box" + }, + { + "name": "sdf3d_translate_4_3_2", + "node_position": { + "x": -834.318359, + "y": 1232.672852 + }, + "parameters": { + "x": 0.12, + "y": -0.03, + "z": 0.18 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_rotate_2", + "node_position": { + "x": -839.193726, + "y": 1471.172852 + }, + "parameters": { + "a": 0, + "ax": -30, + "ay": 45, + "az": 0, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_rotate" + }, + { + "name": "sdf3d_translate_4_3_2_2", + "node_position": { + "x": -835.193726, + "y": 1573.172852 + }, + "parameters": { + "x": 0, + "y": 0.11, + "z": 0.19 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_smoothboolean_3_2_3", + "node_position": { + "x": -623.818359, + "y": 1236.172852 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.09, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_smoothboolean_3_2_2", + "node_position": { + "x": -622.818359, + "y": 1073.172852 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.15, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_translate_4_2_2", + "node_position": { + "x": -832.989258, + "y": 826.922729 + }, + "parameters": { + "x": 0, + "y": 0.24, + "z": 0.01 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_scale", + "node_position": { + "x": -823.989258, + "y": 776.422729 + }, + "parameters": { + "a": 0, + "s": 0.48, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_scale" + }, + { + "name": "sdf3d_smoothboolean_3_2_3_2", + "node_position": { + "x": -602.693726, + "y": 1454.672852 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.03, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_translate_4_2", + "node_position": { + "x": -1141.989258, + "y": 1070.922729 + }, + "parameters": { + "x": 0, + "y": 0.21, + "z": 0.08 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_translate_4_3_3", + "node_position": { + "x": -363.318359, + "y": 1762.672852 + }, + "parameters": { + "x": 0.15, + "y": 0, + "z": 0.18 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Mirror", + "outputs": [ + { + "sdf3d": "$in(vec3(abs($uv.x), $uv.y, $uv.z))", + "type": "sdf3d" + } + ], + "parameters": [ + + ] + }, + "type": "shader" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -1375.989258, + "y": 1121.935181 + }, + "parameters": { + + }, + "ports": [ + + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": -194.318359, + "y": 1767.935181 + }, + "parameters": { + + }, + "ports": [ + { + "name": "port0", + "type": "sdf3d" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -1028.995361, + "y": 476.422729 + }, + "parameters": { + + }, + "type": "remote", + "widgets": [ + + ] + }, + { + "name": "sdf3d_translate_4_3_2_2_2", + "node_position": { + "x": -1172.482544, + "y": 1931.119385 + }, + "parameters": { + "x": 0, + "y": 0.14, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_rotate_2_2", + "node_position": { + "x": -1172.482544, + "y": 1829.119385 + }, + "parameters": { + "a": 0, + "ax": 0, + "ay": 0, + "az": 45, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_rotate" + }, + { + "name": "sdf3d_repeat", + "node_position": { + "x": -1166.482544, + "y": 2035.119385 + }, + "parameters": { + "a": 0, + "c": 15, + "r": 0.24, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 circle_repeat_transform(vec3 p, float count) {\n\tfloat r = 6.28/count;\n\tfloat pa = atan(p.x, p.y);\n\tfloat a = mod(pa+0.5*r, r)-0.5*r;\n\tvec3 rv;\n\tfloat c = cos(a-pa);\n\tfloat s = sin(a-pa);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Circle Repeat", + "outputs": [ + { + "sdf3d": "$in(circle_repeat_transform($uv, $c))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 4, + "label": "", + "max": 32, + "min": 1, + "name": "c", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_rotate_2_2_2", + "node_position": { + "x": -791.235718, + "y": 1859.869385 + }, + "parameters": { + "a": 0, + "ax": -90, + "ay": 0, + "az": 0, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_rotate" + }, + { + "name": "sdf3d_translate_4_3_2_2_2_2", + "node_position": { + "x": -788.235718, + "y": 1967.869385 + }, + "parameters": { + "x": 0, + "y": 0.315, + "z": 0.08 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_cylinder", + "node_position": { + "x": -1161, + "y": 994.5 + }, + "parameters": { + "l": 0.06, + "r": 0.15, + "sx": 0.25, + "sy": 0.25, + "sz": 0.5 + }, + "type": "sdf3d_cylinder" + }, + { + "name": "sdf3d_smoothboolean_3_3", + "node_position": { + "x": -1104.305908, + "y": 815.75 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.1, + "op": 1, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_box_2_2", + "node_position": { + "x": -1190.880981, + "y": 1701 + }, + "parameters": { + "r": 0, + "sx": 0.01, + "sy": 0.01, + "sz": 0.015 + }, + "type": "sdf3d_box" + }, + { + "name": "sdf3d_smoothboolean_3_2_3_2_2", + "node_position": { + "x": -562.468933, + "y": 1761.75 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.05, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_smoothboolean" + }, + { + "name": "sdf3d_sphere_2_3", + "node_position": { + "x": -1165.397095, + "y": 2204.25 + }, + "parameters": { + "r": 0.28 + }, + "type": "sdf3d_sphere" + }, + { + "name": "sdf3d_translate_4_3_2_2_2_3", + "node_position": { + "x": -1175.397095, + "y": 2261.5 + }, + "parameters": { + "x": 0, + "y": 0.28, + "z": 0 + }, + "type": "sdf3d_translate" + }, + { + "name": "sdf3d_boolean", + "node_position": { + "x": -990.397095, + "y": 2076 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 2, + "r": 0.3, + "w": 0.28 + }, + "type": "sdf3d_boolean" + }, + { + "name": "sdroundedshape", + "node_position": { + "x": -794.225342, + "y": 2070.75 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.15, + "op": 0, + "r": 0.01, + "w": 0.28 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rounded", + "outputs": [ + { + "sdf3d": "$in($uv)-$r", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "sdf3d_rotate_2_2_3", + "node_position": { + "x": -1172.268311, + "y": 2085.75 + }, + "parameters": { + "a": 0, + "ax": 0, + "ay": 0, + "az": 11, + "x": 0.35, + "y": 0, + "z": 0 + }, + "type": "sdf3d_rotate" + } + ], + "parameters": { + + }, + "type": "graph" + }, + { + "name": "buffer", + "node_position": { + "x": -353.830994, + "y": 1560.222534 + }, + "parameters": { + "lod": 0, + "size": 11 + }, + "type": "buffer" + }, + { + "name": "blend_3", + "node_position": { + "x": 84.334427, + "y": 1296.834595 + }, + "parameters": { + "amount": 1, + "blend_type": 3 + }, + "type": "blend" + } + ], + "parameters": { + + }, + "type": "graph" +} \ No newline at end of file diff --git a/addons/material_maker/graph_edit.gd b/addons/material_maker/graph_edit.gd index 5dbcec3..707c92e 100644 --- a/addons/material_maker/graph_edit.gd +++ b/addons/material_maker/graph_edit.gd @@ -22,6 +22,9 @@ signal graph_changed func _ready() -> void: OS.low_processor_usage_mode = true center_view() + for t in range(5): + add_valid_connection_type(t, 42) + add_valid_connection_type(42, t) func _gui_input(event) -> void: if event is InputEventKey and event.pressed: diff --git a/addons/material_maker/library.gd b/addons/material_maker/library.gd index 353f022..0980dac 100644 --- a/addons/material_maker/library.gd +++ b/addons/material_maker/library.gd @@ -64,8 +64,10 @@ func get_preview_texture(data : Dictionary) -> ImageTexture: image_path = ProjectSettings.globalize_path(image_path) t = ImageTexture.new() var image : Image = Image.new() - image.load(image_path) - t.create_from_image(image) + if image.load(image_path) == OK: + t.create_from_image(image) + else: + print("Cannot load image "+image_path) return t return null diff --git a/addons/material_maker/library/base.json b/addons/material_maker/library/base.json index 19eaab4..adf3eb7 100644 --- a/addons/material_maker/library/base.json +++ b/addons/material_maker/library/base.json @@ -587,30 +587,7 @@ "parameters": { }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "vec4($uv, 0.0, 1.0)", - "label": "", - "name": "in", - "type": "rgba" - } - ], - "instance": "", - "name": "CircleMap", - "outputs": [ - { - "rgba": "$in(vec2(fract(atan($uv.y-0.5, $uv.x-0.5)*0.15915494309), 2.0*length($uv-vec2(0.5))))", - "type": "rgba" - } - ], - "parameters": [ - - ] - }, - "type": "shader" + "type": "circle_map" }, { "name": "gen_parameters", @@ -723,6 +700,25 @@ "tree_item": "Simple/Gradient/Circular", "type": "graph" }, + { + "collapsed": true, + "icon": "simple_sdf_sdshow", + "name": "sdshow", + "parameters": { + "bevel": 0.1, + "cx": 0, + "cy": 0, + "h": 0.08, + "r": 0.3, + "w": 0.28 + }, + "tree_item": "Simple/SDF/sdShow", + "type": "sdshow" + }, + { + "collapsed": false, + "tree_item": "Simple/SDF/Shapes" + }, { "collapsed": true, "icon": "simple_sdf_shapes_sdcircle", @@ -730,7 +726,7 @@ "parameters": { "cx": 0, "cy": 0, - "r": 0.25 + "r": 0.4 }, "tree_item": "Simple/SDF/Shapes/sdCircle", "type": "sdcircle" @@ -781,6 +777,26 @@ "tree_item": "Simple/SDF/Shapes/sdRhombus", "type": "sdrhombus" }, + { + "collapsed": true, + "icon": "simple_sdf_shapes_sdarc", + "name": "sdarc", + "parameters": { + "a1": 0, + "a2": 0, + "cx": 0, + "cy": 0, + "r": 0.4, + "r1": 0.3, + "r2": 0.1 + }, + "tree_item": "Simple/SDF/Shapes/sdArc", + "type": "sdarc" + }, + { + "collapsed": false, + "tree_item": "Simple/SDF/Operators" + }, { "collapsed": true, "icon": "simple_sdf_operators_sdboolean", @@ -811,65 +827,8 @@ "r": 0.3, "w": 0.28 }, - "shader_model": { - "code": "", - "global": "float sdSmoothUnion( float d1, float d2, float k ) {\n float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 );\n return mix( d2, d1, h ) - k*h*(1.0-h); }\n\nfloat sdSmoothSubtraction( float d1, float d2, float k ) {\n float h = clamp( 0.5 - 0.5*(d2+d1)/k, 0.0, 1.0 );\n return mix( d2, -d1, h ) + k*h*(1.0-h); }\n\nfloat sdSmoothIntersection( float d1, float d2, float k ) {\n float h = clamp( 0.5 - 0.5*(d2-d1)/k, 0.0, 1.0 );\n return mix( d2, d1, h ) + k*h*(1.0-h); }\n", - "inputs": [ - { - "default": "0.0", - "label": "", - "name": "in1", - "type": "f" - }, - { - "default": "0.0", - "label": "", - "name": "in2", - "type": "f" - } - ], - "instance": "", - "name": "sdSmoothBoolean", - "outputs": [ - { - "f": "sdSmooth$op($in1($uv), $in2($uv), $k)", - "type": "f" - } - ], - "parameters": [ - { - "default": 0, - "label": "", - "name": "op", - "type": "enum", - "values": [ - { - "name": "Union", - "value": "Union" - }, - { - "name": "Subtraction", - "value": "Subtraction" - }, - { - "name": "Intersection", - "value": "Intersection" - } - ] - }, - { - "default": 0, - "label": "", - "max": 1, - "min": 0, - "name": "k", - "step": 0.01, - "type": "float" - } - ] - }, "tree_item": "Simple/SDF/Operators/sdSmoothBoolean", - "type": "shader" + "type": "sdsmoothboolean" }, { "collapsed": true, @@ -882,7 +841,7 @@ "h": 0.08, "k": 0.15, "op": 0, - "r": 0.1, + "r": 0.2, "w": 0.28 }, "tree_item": "Simple/SDF/Operators/sdRoundedShape", @@ -899,57 +858,316 @@ "h": 0.08, "k": 0.15, "op": 0, - "r": 0.05, + "r": 0.1, "w": 0.28 }, "tree_item": "Simple/SDF/Operators/sdAnnularShape", "type": "sdannularshape" }, + { + "collapsed": false, + "tree_item": "Simple/SDF/Transforms" + }, { "collapsed": true, - "icon": "simple_sdf_operators_sdshow", - "name": "sdshow", + "icon": "simple_sdf_transforms_translate", + "name": "sdtranslate", "parameters": { - "bevel": 0.1, + "x": 0, + "y": 0, + "z": 0 + }, + "tree_item": "Simple/SDF/Transforms/Translate", + "type": "sdtranslate" + }, + { + "collapsed": true, + "icon": "simple_sdf_transforms_rotate", + "name": "sdrotate", + "parameters": { + "a": 0, + "x": 0.35, + "y": 0, + "z": 0 + }, + "tree_item": "Simple/SDF/Transforms/Rotate", + "type": "sdrotate" + }, + { + "collapsed": true, + "icon": "simple_sdf_transforms_scale", + "name": "sdscale_2", + "parameters": { + "a": 0, + "s": 1, + "x": 0.35, + "y": 0, + "z": 0 + }, + "tree_item": "Simple/SDF/Transforms/Scale", + "type": "sdscale" + }, + { + "collapsed": false, + "tree_item": "3D" + }, + { + "collapsed": true, + "icon": "3d_sdf_render", + "name": "raymarching", + "parameters": { + + }, + "tree_item": "3D/SDF/Render", + "type": "raymarching" + }, + { + "collapsed": false, + "tree_item": "3D/SDF/Shapes" + }, + { + "collapsed": true, + "icon": "3d_sdf_shapes_sphere", + "name": "sdf3d_sphere", + "parameters": { + "r": 0.4 + }, + "tree_item": "3D/SDF/Shapes/Sphere", + "type": "sdf3d_sphere" + }, + { + "collapsed": true, + "icon": "3d_sdf_shapes_box", + "name": "sdf3d_box", + "parameters": { + "r": 0.01, + "sx": 0.3, + "sy": 0.25, + "sz": 0.25 + }, + "tree_item": "3D/SDF/Shapes/Box", + "type": "sdf3d_box" + }, + { + "collapsed": true, + "icon": "3d_sdf_shapes_cylinder", + "name": "sdf3d_cylinder", + "parameters": { + "l": 0.25, + "r": 0.25, + "sx": 0.25, + "sy": 0.25, + "sz": 0.5 + }, + "tree_item": "3D/SDF/Shapes/Cylinder", + "type": "sdf3d_cylinder" + }, + { + "collapsed": true, + "icon": "3d_sdf_shapes_capsule", + "name": "sdf3d_capsule", + "parameters": { + "l": 0.3, + "r": 0.2, + "sx": 0.25, + "sy": 0.25, + "sz": 0.5 + }, + "tree_item": "3D/SDF/Shapes/Capsule", + "type": "sdf3d_capsule" + }, + { + "collapsed": true, + "icon": "3d_sdf_shapes_cone", + "name": "sdf3d_cone", + "parameters": { + "a": 30, + "r": 0, + "sx": 0.01, + "sy": 0.01, + "sz": 0.015 + }, + "tree_item": "3D/SDF/Shapes/Cone", + "type": "sdf3d_cone" + }, + { + "collapsed": true, + "icon": "3d_sdf_shapes_torus", + "name": "sdf3d_torus", + "parameters": { + "R": 0.3, + "r": 0.15, + "sx": 0.1, + "sy": 0.1, + "sz": 0.02 + }, + "tree_item": "3D/SDF/Shapes/Torus", + "type": "sdf3d_torus" + }, + { + "collapsed": false, + "tree_item": "3D/SDF/Operators" + }, + { + "collapsed": true, + "icon": "3d_sdf_operators_boolean", + "name": "sdf3d_boolean", + "parameters": { + "bevel": 0, "cx": 0, "cy": 0, "h": 0.08, + "op": 0, "r": 0.3, "w": 0.28 }, - "shader_model": { - "code": "", - "global": "", - "inputs": [ - { - "default": "0.0", - "label": "", - "name": "in", - "type": "f" - } - ], - "instance": "", - "name": "sdShow", - "outputs": [ - { - "f": "clamp(-$in($uv)/max($bevel, 0.00001), 0.0, 1.0)", - "type": "f" - } - ], - "parameters": [ - { - "default": 0, - "label": "Bevel", - "max": 1, - "min": 0, - "name": "bevel", - "step": 0.01, - "type": "float" - } - ] + "tree_item": "3D/SDF/Operators/Boolean", + "type": "sdf3d_boolean" + }, + { + "collapsed": true, + "icon": "3d_sdf_operators_smoothboolean", + "name": "sdf3d_smoothboolean", + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.15, + "op": 0, + "r": 0.3, + "w": 0.28 }, - "tree_item": "Simple/SDF/Operators/sdShow", - "type": "shader" + "tree_item": "3D/SDF/Operators/SmoothBoolean", + "type": "sdf3d_smoothboolean" + }, + { + "collapsed": true, + "icon": "3d_sdf_operators_rounded", + "name": "sdf3d_rounded", + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.15, + "op": 0, + "r": 0.15, + "w": 0.28 + }, + "tree_item": "3D/SDF/Operators/Rounded", + "type": "sdf3d_rounded" + }, + { + "collapsed": true, + "icon": "3d_sdf_operators_repeat", + "name": "sdf3d_repeat", + "parameters": { + "a": 0, + "r": 0.3, + "rx": 3, + "ry": 3, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "tree_item": "3D/SDF/Operators/Repeat", + "type": "sdf3d_repeat" + }, + { + "collapsed": true, + "icon": "3d_sdf_operators_circlerepeat", + "name": "sdf3d_circle_repeat", + "parameters": { + "a": 0, + "c": 5, + "r": 0.24, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "tree_item": "3D/SDF/Operators/CircleRepeat", + "type": "sdf3d_circle_repeat" + }, + { + "collapsed": true, + "icon": "3d_sdf_operators_extrusion", + "name": "sdf3d_extrusion", + "parameters": { + "a": 0, + "d": 0.3, + "s": 1, + "x": 0.35, + "y": 0, + "z": 0 + }, + "tree_item": "3D/SDF/Operators/Extrusion", + "type": "sdf3d_extrusion" + }, + { + "collapsed": true, + "icon": "3d_sdf_operators_revolution", + "name": "sdf3d_revolution", + "parameters": { + "a": 0, + "d": 0.25, + "s": 1, + "x": 0.35, + "y": 0, + "z": 0 + }, + "tree_item": "3D/SDF/Operators/Revolution", + "type": "sdf3d_revolution" + }, + { + "collapsed": false, + "tree_item": "3D/SDF/Transforms" + }, + { + "collapsed": true, + "icon": "3d_sdf_transforms_translate", + "name": "sdf3d_translate_3_2", + "parameters": { + "x": 0, + "y": 0, + "z": 0 + }, + "tree_item": "3D/SDF/Transforms/Translate", + "type": "sdf3d_translate" + }, + { + "collapsed": true, + "icon": "3d_sdf_transforms_scale", + "name": "sdf3d_scale_2", + "parameters": { + "a": 0, + "s": 1, + "x": 0.35, + "y": 0, + "z": 0 + }, + "tree_item": "3D/SDF/Transforms/Scale", + "type": "sdf3d_scale" + }, + { + "collapsed": true, + "icon": "3d_sdf_transforms_rotate", + "name": "sdf3d_rotate_2", + "parameters": { + "a": 0, + "ax": 0, + "ay": 0, + "az": 0, + "x": 0.35, + "y": 0, + "z": 0 + }, + "tree_item": "3D/SDF/Transforms/Rotate", + "type": "sdf3d_rotate" }, { "collapsed": false, @@ -1130,7 +1348,7 @@ ], "icon": "pattern_fibers", "label": "Fibers", - "name": "graph", + "name": "graph_4", "nodes": [ { "name": "transform", @@ -1140,7 +1358,7 @@ }, "parameters": { "repeat": true, - "rotate": 45, + "rotate": 30.125, "scale_x": 0.5, "scale_y": 1, "translate_x": 0.975, @@ -1156,6 +1374,7 @@ }, "parameters": { "gradient": { + "interpolation": 1, "points": [ { "a": 1, @@ -1186,9 +1405,11 @@ "parameters": { "bevel": 0.1, "columns": 4, + "corner": 0, "mortar": 0.1, "pattern": 0, "repeat": 1, + "round": 0, "row_offset": 0.5, "rows": 1 }, @@ -1239,8 +1460,8 @@ { "name": "gen_parameters", "node_position": { - "x": -433.557495, - "y": -236.5 + "x": -429.557495, + "y": -266.5 }, "parameters": { "param0": 4 @@ -1322,6 +1543,17 @@ "tree_item": "Pattern/Scratches", "type": "scratches" }, + { + "collapsed": true, + "icon": "pattern_beehive", + "name": "beehive", + "parameters": { + "sx": 4, + "sy": 4 + }, + "tree_item": "Pattern/Beehive", + "type": "beehive" + }, { "collapsed": false, "icon": "noise", diff --git a/addons/material_maker/library/base/3d_sdf_operators_boolean.png b/addons/material_maker/library/base/3d_sdf_operators_boolean.png new file mode 100644 index 0000000..5845712 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_operators_boolean.png differ diff --git a/addons/material_maker/library/base/3d_sdf_operators_circlerepeat.png b/addons/material_maker/library/base/3d_sdf_operators_circlerepeat.png new file mode 100644 index 0000000..1c72124 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_operators_circlerepeat.png differ diff --git a/addons/material_maker/library/base/3d_sdf_operators_extrusion.png b/addons/material_maker/library/base/3d_sdf_operators_extrusion.png new file mode 100644 index 0000000..c27c488 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_operators_extrusion.png differ diff --git a/addons/material_maker/library/base/3d_sdf_operators_repeat.png b/addons/material_maker/library/base/3d_sdf_operators_repeat.png new file mode 100644 index 0000000..dae1635 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_operators_repeat.png differ diff --git a/addons/material_maker/library/base/3d_sdf_operators_revolution.png b/addons/material_maker/library/base/3d_sdf_operators_revolution.png new file mode 100644 index 0000000..530fd41 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_operators_revolution.png differ diff --git a/addons/material_maker/library/base/3d_sdf_operators_rounded.png b/addons/material_maker/library/base/3d_sdf_operators_rounded.png new file mode 100644 index 0000000..accd2d4 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_operators_rounded.png differ diff --git a/addons/material_maker/library/base/3d_sdf_operators_smoothboolean.png b/addons/material_maker/library/base/3d_sdf_operators_smoothboolean.png new file mode 100644 index 0000000..7abd17f Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_operators_smoothboolean.png differ diff --git a/addons/material_maker/library/base/3d_sdf_render.png b/addons/material_maker/library/base/3d_sdf_render.png new file mode 100644 index 0000000..4fab799 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_render.png differ diff --git a/addons/material_maker/library/base/3d_sdf_shapes_box.png b/addons/material_maker/library/base/3d_sdf_shapes_box.png new file mode 100644 index 0000000..b8c3cb7 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_shapes_box.png differ diff --git a/addons/material_maker/library/base/3d_sdf_shapes_capsule.png b/addons/material_maker/library/base/3d_sdf_shapes_capsule.png new file mode 100644 index 0000000..fef46af Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_shapes_capsule.png differ diff --git a/addons/material_maker/library/base/3d_sdf_shapes_cone.png b/addons/material_maker/library/base/3d_sdf_shapes_cone.png new file mode 100644 index 0000000..052f378 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_shapes_cone.png differ diff --git a/addons/material_maker/library/base/3d_sdf_shapes_cylinder.png b/addons/material_maker/library/base/3d_sdf_shapes_cylinder.png new file mode 100644 index 0000000..68a6948 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_shapes_cylinder.png differ diff --git a/addons/material_maker/library/base/3d_sdf_shapes_sphere.png b/addons/material_maker/library/base/3d_sdf_shapes_sphere.png new file mode 100644 index 0000000..96906bc Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_shapes_sphere.png differ diff --git a/addons/material_maker/library/base/3d_sdf_shapes_torus.png b/addons/material_maker/library/base/3d_sdf_shapes_torus.png new file mode 100644 index 0000000..958cc70 Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_shapes_torus.png differ diff --git a/addons/material_maker/library/base/3d_sdf_transforms_rotate.png b/addons/material_maker/library/base/3d_sdf_transforms_rotate.png new file mode 100644 index 0000000..b3b048d Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_transforms_rotate.png differ diff --git a/addons/material_maker/library/base/3d_sdf_transforms_scale.png b/addons/material_maker/library/base/3d_sdf_transforms_scale.png new file mode 100644 index 0000000..a72817c Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_transforms_scale.png differ diff --git a/addons/material_maker/library/base/3d_sdf_transforms_translate.png b/addons/material_maker/library/base/3d_sdf_transforms_translate.png new file mode 100644 index 0000000..1ecf68d Binary files /dev/null and b/addons/material_maker/library/base/3d_sdf_transforms_translate.png differ diff --git a/addons/material_maker/library/base/pattern_beehive.png b/addons/material_maker/library/base/pattern_beehive.png new file mode 100644 index 0000000..854dba4 Binary files /dev/null and b/addons/material_maker/library/base/pattern_beehive.png differ diff --git a/addons/material_maker/library/base/pattern_fibers.png b/addons/material_maker/library/base/pattern_fibers.png index fab5f50..94d73f8 100644 Binary files a/addons/material_maker/library/base/pattern_fibers.png and b/addons/material_maker/library/base/pattern_fibers.png differ diff --git a/addons/material_maker/library/base/simple_sdf_operators_sdannularshape.png b/addons/material_maker/library/base/simple_sdf_operators_sdannularshape.png index f86793b..a5b7bfd 100644 Binary files a/addons/material_maker/library/base/simple_sdf_operators_sdannularshape.png and b/addons/material_maker/library/base/simple_sdf_operators_sdannularshape.png differ diff --git a/addons/material_maker/library/base/simple_sdf_operators_sdboolean.png b/addons/material_maker/library/base/simple_sdf_operators_sdboolean.png index a23356b..4cf32ac 100644 Binary files a/addons/material_maker/library/base/simple_sdf_operators_sdboolean.png and b/addons/material_maker/library/base/simple_sdf_operators_sdboolean.png differ diff --git a/addons/material_maker/library/base/simple_sdf_operators_sdroundedshape.png b/addons/material_maker/library/base/simple_sdf_operators_sdroundedshape.png index 49e4624..1719bc4 100644 Binary files a/addons/material_maker/library/base/simple_sdf_operators_sdroundedshape.png and b/addons/material_maker/library/base/simple_sdf_operators_sdroundedshape.png differ diff --git a/addons/material_maker/library/base/simple_sdf_operators_sdshow.png b/addons/material_maker/library/base/simple_sdf_operators_sdshow.png deleted file mode 100644 index eaf638b..0000000 Binary files a/addons/material_maker/library/base/simple_sdf_operators_sdshow.png and /dev/null differ diff --git a/addons/material_maker/library/base/simple_sdf_operators_sdsmoothboolean.png b/addons/material_maker/library/base/simple_sdf_operators_sdsmoothboolean.png index 45e2a99..f559db0 100644 Binary files a/addons/material_maker/library/base/simple_sdf_operators_sdsmoothboolean.png and b/addons/material_maker/library/base/simple_sdf_operators_sdsmoothboolean.png differ diff --git a/addons/material_maker/library/base/simple_sdf_sdshow.png b/addons/material_maker/library/base/simple_sdf_sdshow.png new file mode 100644 index 0000000..43e8b2b Binary files /dev/null and b/addons/material_maker/library/base/simple_sdf_sdshow.png differ diff --git a/addons/material_maker/library/base/simple_sdf_shapes_sdarc.png b/addons/material_maker/library/base/simple_sdf_shapes_sdarc.png new file mode 100644 index 0000000..dca4d06 Binary files /dev/null and b/addons/material_maker/library/base/simple_sdf_shapes_sdarc.png differ diff --git a/addons/material_maker/library/base/simple_sdf_shapes_sdbox.png b/addons/material_maker/library/base/simple_sdf_shapes_sdbox.png index 3e65d3d..9441661 100644 Binary files a/addons/material_maker/library/base/simple_sdf_shapes_sdbox.png and b/addons/material_maker/library/base/simple_sdf_shapes_sdbox.png differ diff --git a/addons/material_maker/library/base/simple_sdf_shapes_sdcircle.png b/addons/material_maker/library/base/simple_sdf_shapes_sdcircle.png index 61924e0..df75625 100644 Binary files a/addons/material_maker/library/base/simple_sdf_shapes_sdcircle.png and b/addons/material_maker/library/base/simple_sdf_shapes_sdcircle.png differ diff --git a/addons/material_maker/library/base/simple_sdf_shapes_sdline.png b/addons/material_maker/library/base/simple_sdf_shapes_sdline.png index 0c783f9..47d3bac 100644 Binary files a/addons/material_maker/library/base/simple_sdf_shapes_sdline.png and b/addons/material_maker/library/base/simple_sdf_shapes_sdline.png differ diff --git a/addons/material_maker/library/base/simple_sdf_shapes_sdrhombus.png b/addons/material_maker/library/base/simple_sdf_shapes_sdrhombus.png index 8be1c67..758a86f 100644 Binary files a/addons/material_maker/library/base/simple_sdf_shapes_sdrhombus.png and b/addons/material_maker/library/base/simple_sdf_shapes_sdrhombus.png differ diff --git a/addons/material_maker/library/base/simple_sdf_transforms_rotate.png b/addons/material_maker/library/base/simple_sdf_transforms_rotate.png new file mode 100644 index 0000000..1f0a166 Binary files /dev/null and b/addons/material_maker/library/base/simple_sdf_transforms_rotate.png differ diff --git a/addons/material_maker/library/base/simple_sdf_transforms_scale.png b/addons/material_maker/library/base/simple_sdf_transforms_scale.png new file mode 100644 index 0000000..a2b15b2 Binary files /dev/null and b/addons/material_maker/library/base/simple_sdf_transforms_scale.png differ diff --git a/addons/material_maker/library/base/simple_sdf_transforms_translate.png b/addons/material_maker/library/base/simple_sdf_transforms_translate.png new file mode 100644 index 0000000..b712663 Binary files /dev/null and b/addons/material_maker/library/base/simple_sdf_transforms_translate.png differ diff --git a/addons/material_maker/main_window.gd b/addons/material_maker/main_window.gd index 1d9855a..198b3d8 100644 --- a/addons/material_maker/main_window.gd +++ b/addons/material_maker/main_window.gd @@ -383,7 +383,7 @@ func do_add_to_user_library(name, nodes) -> void: dir.make_dir("user://library/user") data.library = "user://library/user.json" data.icon = library.get_icon_name(name) - var result = nodes[0].generator.render(0, 64) + var result = nodes[0].generator.render(0, 64, true) while result is GDScriptFunctionState: result = yield(result, "completed") result.save_to_file("user://library/user/"+data.icon+".png") @@ -480,7 +480,7 @@ func update_preview_2d(node = null) -> void: node = n break if node != null: - var result = node.generator.render(0, 1024) + var result = node.generator.render(0, 1024, true) while result is GDScriptFunctionState: result = yield(result, "completed") var tex = ImageTexture.new() diff --git a/addons/material_maker/main_window.tscn b/addons/material_maker/main_window.tscn index 4e72a8b..19c18dc 100644 --- a/addons/material_maker/main_window.tscn +++ b/addons/material_maker/main_window.tscn @@ -66,7 +66,7 @@ margin_left = 125.0 margin_right = 171.0 margin_bottom = 20.0 text = "Tools" -items = [ "Create", null, 0, false, false, -1, 0, null, "PopupMenu", false, "Create group", null, 0, false, false, 19, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 20, 268435543, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Add selected node to user library", null, 0, false, false, 22, 0, null, "", false, "Export the nodes library", null, 0, false, false, 23, 0, null, "", false ] +items = [ "Create", null, 0, false, false, 0, 0, null, "PopupMenu", false, "Create group", null, 0, false, false, 19, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 20, 268435543, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Add selected node to user library", null, 0, false, false, 22, 0, null, "", false, "Export the nodes library", null, 0, false, false, 23, 0, null, "", false ] [node name="Help" type="MenuButton" parent="VBoxContainer/Menu"] margin_left = 175.0 diff --git a/addons/material_maker/nodes/debug.gd b/addons/material_maker/nodes/debug.gd index 07bbda2..2cb9545 100644 --- a/addons/material_maker/nodes/debug.gd +++ b/addons/material_maker/nodes/debug.gd @@ -16,7 +16,10 @@ static func generate_shader(src_code) -> String: var shader_code = src_code.defs shader_code += "\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\nvec2 UV = fragCoord/iResolution.xy;\n" shader_code += src_code.code - shader_code += "fragColor = "+src_code.rgba+";\n" + if src_code.has("rgba"): + shader_code += "fragColor = "+src_code.rgba+";\n" + else: + shader_code += "fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" shader_code += "}\n" #print("GENERATED SHADER:\n"+shader_code) code += shader_code diff --git a/addons/material_maker/nodes/generic.gd b/addons/material_maker/nodes/generic.gd index a6820a4..10fe434 100644 --- a/addons/material_maker/nodes/generic.gd +++ b/addons/material_maker/nodes/generic.gd @@ -134,7 +134,7 @@ func create_parameter_control(p : Dictionary) -> Control: return control func save_preview_widget() -> void: - if preview != null: + if preview != null and preview.get_parent() == self: remove_child(preview) if preview_timer != null: preview_timer.stop() @@ -174,16 +174,12 @@ func update_node() -> void: var input = inputs[i] var enable_left = false var color_left = Color(0.5, 0.5, 0.5) + var type_left = 0 if typeof(input) == TYPE_DICTIONARY: - if input.type == "rgb": - enable_left = true - color_left = Color(0.5, 0.5, 1.0) - elif input.type == "rgba": - enable_left = true - color_left = Color(0.0, 0.5, 0.0, 0.5) - else: - enable_left = true - set_slot(i, enable_left, 0, color_left, false, 0, Color()) + enable_left = true + color_left = MMGenBase.PORT_TYPES[input.type].color + type_left = MMGenBase.PORT_TYPES[input.type].slot_type + set_slot(i, enable_left, type_left, color_left, false, 0, Color()) var hsizer : HBoxContainer = HBoxContainer.new() hsizer.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL if input.has("label") and input.label != "": @@ -240,7 +236,8 @@ func update_node() -> void: label_widget.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL hsizer.add_child(label_widget) control.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL - hsizer.add_child(control) + if hsizer != null: + hsizer.add_child(control) initialize_properties() # Outputs var outputs = generator.get_output_defs() @@ -248,15 +245,15 @@ func update_node() -> void: output_count = outputs.size() for i in range(output_count): var output = outputs[i] - var enable_right = true - var color_right = Color(0.5, 0.5, 0.5) + var enable_right : bool = true + var color_right : Color = Color(0.5, 0.5, 0.5) + var type_right : int = 0 assert(typeof(output) == TYPE_DICTIONARY) assert(output.has("type")) enable_right = true - match output.type: - "rgb": color_right = Color(0.5, 0.5, 1.0) - "rgba": color_right = Color(0.0, 0.5, 0.0, 0.5) - set_slot(i, is_slot_enabled_left(i), get_slot_type_left(i), get_slot_color_left(i), enable_right, 0, color_right) + color_right = MMGenBase.PORT_TYPES[output.type].color + type_right = MMGenBase.PORT_TYPES[output.type].slot_type + set_slot(i, is_slot_enabled_left(i), get_slot_type_left(i), get_slot_color_left(i), enable_right, type_right, color_right) var hsizer : HBoxContainer while i >= get_child_count(): hsizer = HBoxContainer.new() @@ -383,7 +380,7 @@ func update_preview(size : int = 0) -> void: preview_timer.start(0.2) func do_update_preview() -> void: - var result = generator.render(preview_index, preview_size) + var result = generator.render(preview_index, preview_size, true) while result is GDScriptFunctionState: result = yield(result, "completed") if preview.texture == null: diff --git a/addons/material_maker/nodes/ios.gd b/addons/material_maker/nodes/ios.gd index 99ee5cb..fd86ad7 100644 --- a/addons/material_maker/nodes/ios.gd +++ b/addons/material_maker/nodes/ios.gd @@ -22,12 +22,14 @@ func update_node() -> void: title = generator.get_type_name() var color = Color(0.0, 0.5, 0.0, 0.5) for p in generator.get_io_defs(): + color = MMGenBase.PORT_TYPES[p.type].color set_slot(get_child_count(), generator.name != "gen_inputs", 0, color, generator.name != "gen_outputs", 0, color) var port : Control if generator.is_editable(): port = preload("res://addons/material_maker/nodes/ios/port.tscn").instance() if p.has("name"): port.set_label(p.name) + port.set_type(p.type) else: port = Label.new() port.text = p.name diff --git a/addons/material_maker/nodes/ios/port.gd b/addons/material_maker/nodes/ios/port.gd index 8f2d297..54f8e6a 100644 --- a/addons/material_maker/nodes/ios/port.gd +++ b/addons/material_maker/nodes/ios/port.gd @@ -3,6 +3,9 @@ extends HBoxContainer func set_label(l : String) -> void: $Name.set_text(l) +func set_type(t : String) -> void: + $Type.selected = MMGenBase.PORT_TYPE_NAMES.find(t) + func update_up_down_button() -> void: var parent = get_parent() if parent == null: @@ -13,6 +16,9 @@ func update_up_down_button() -> void: func _on_Name_label_changed(new_label) -> void: get_parent().generator.set_port_name(get_index(), new_label) +func _on_Type_item_selected(ID) -> void: + get_parent().generator.set_port_type(get_index(), MMGenBase.PORT_TYPE_NAMES[ID]) + func _on_Delete_pressed() -> void: get_parent().generator.delete_port(get_index()) diff --git a/addons/material_maker/nodes/ios/port.tscn b/addons/material_maker/nodes/ios/port.tscn index 79529cf..62545f1 100644 --- a/addons/material_maker/nodes/ios/port.tscn +++ b/addons/material_maker/nodes/ios/port.tscn @@ -48,7 +48,18 @@ margin_left = 84.0 margin_right = 114.0 margin_bottom = 20.0 rect_min_size = Vector2( 30, 0 ) + +[node name="Type" type="OptionButton" parent="."] +margin_left = 118.0 +margin_right = 222.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 102, 0 ) +hint_tooltip = "Input flag" +text = "Greyscale" +items = [ "Greyscale", null, false, 0, null, "Color", null, false, 1, null, "RGBA", null, false, 2, null, "SDF2D", null, false, 3, null, "SDF3D", null, false, 4, null ] +selected = 0 [connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"] [connection signal="pressed" from="Up" to="." method="_on_Up_pressed"] [connection signal="pressed" from="Down" to="." method="_on_Down_pressed"] [connection signal="label_changed" from="Name" to="." method="_on_Name_label_changed"] +[connection signal="item_selected" from="Type" to="." method="_on_Type_item_selected"] diff --git a/addons/material_maker/nodes/raymarching.mmg b/addons/material_maker/nodes/raymarching.mmg new file mode 100644 index 0000000..770058a --- /dev/null +++ b/addons/material_maker/nodes/raymarching.mmg @@ -0,0 +1,39 @@ +{ + "name": "raymarching", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "float $(name_uv)_d = raymarch_$name($uv);\n", + "global": "", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "name": "sdf", + "type": "sdf3d" + } + ], + "instance": "float input_$name(vec3 p) {\n\tif (p.z > 0.0) {\n\t\treturn $sdf(p);\n\t} else {\n\t\treturn p.z;\n\t}\n}\n\nfloat raymarch_$name(vec2 uv) {\n\tvec3 ro = vec3(uv-vec2(0.5), 1.0);\n\tvec3 rd = vec3(0.0, 0.0, -1.0);\n\tfloat dO=0.;\n \n for (int i=0; i < 25; i++) {\n \tvec3 p = ro + rd*dO;\n float dS = input_$name(p);\n dO += dS;\n if (dO > 1.0 || dS < 0.0001) break;\n }\n \n return dO;\n}\n\nvec3 normal_$name(vec3 p) {\n\tfloat d = input_$name(p);\n float e = .001;\n \n vec3 n = d - vec3(\n input_$name(p-vec3(e, 0.0, 0.0)),\n input_$name(p-vec3(0.0, e, 0.0)),\n input_$name(p-vec3(0.0, 0.0, e)));\n \n return vec3(-1.0, -1.0, -1.0)*normalize(n);\n}\n\n", + "name": "Raymarching", + "outputs": [ + { + "f": "1.0-$(name_uv)_d", + "type": "f" + }, + { + "rgb": "vec3(0.5)+0.5*normal_$name(vec3($uv-vec2(0.5), 1.0-$(name_uv)_d))", + "type": "rgb" + } + ], + "parameters": [ + + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdannularshape.mmg b/addons/material_maker/nodes/sdannularshape.mmg index 9939b9d..12124a2 100644 --- a/addons/material_maker/nodes/sdannularshape.mmg +++ b/addons/material_maker/nodes/sdannularshape.mmg @@ -22,15 +22,15 @@ "default": "0.0", "label": "", "name": "in", - "type": "f" + "type": "sdf2d" } ], "instance": "", "name": "sdAnnularShape", "outputs": [ { - "f": "abs($in($uv)) - $r", - "type": "f" + "sdf2d": "abs($in($uv))-$r", + "type": "sdf2d" } ], "parameters": [ diff --git a/addons/material_maker/nodes/sdarc.mmg b/addons/material_maker/nodes/sdarc.mmg new file mode 100644 index 0000000..6bb49ba --- /dev/null +++ b/addons/material_maker/nodes/sdarc.mmg @@ -0,0 +1,70 @@ +{ + "name": "sdarc", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a1": 0, + "a2": 0, + "cx": 0, + "cy": 0, + "r": 0.4, + "r1": 0.3, + "r2": 0.1 + }, + "shader_model": { + "code": "", + "global": "float sdArc(vec2 p, vec2 sca, vec2 scb, float ra, float rb) {\n p *= mat2(vec2(sca.x,sca.y),vec2(-sca.y,sca.x));\n p.x = abs(p.x);\n float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p.xy);\n return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;\n}", + "inputs": [ + + ], + "instance": "", + "name": "sdArc", + "outputs": [ + { + "sdf2d": "sdArc($uv-vec2(0.5), vec2(cos($a1*0.01745329251), sin($a1*0.01745329251)), vec2(cos($a2*0.01745329251), sin($a2*0.01745329251)), $r1, $r2)", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": 0, + "label": "Angle 1", + "max": 180, + "min": -180, + "name": "a1", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Angle 2", + "max": 180, + "min": -180, + "name": "a2", + "step": 1, + "type": "float" + }, + { + "default": 0.5, + "label": "Radius 1", + "max": 1, + "min": 0, + "name": "r1", + "step": 0.01, + "type": "float" + }, + { + "default": 0.1, + "label": "Radius 2", + "max": 1, + "min": 0, + "name": "r2", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdboolean.mmg b/addons/material_maker/nodes/sdboolean.mmg index 8606dab..b821949 100644 --- a/addons/material_maker/nodes/sdboolean.mmg +++ b/addons/material_maker/nodes/sdboolean.mmg @@ -9,53 +9,53 @@ "cx": 0, "cy": 0, "h": 0.08, - "op": 0, + "op": 1, "r": 0.3, "w": 0.28 }, "shader_model": { "code": "", - "global": "float sdUnion( float d1, float d2 ) { return min(d1,d2); }\nfloat sdSubtraction( float d1, float d2 ) { return max(-d1,d2); }\nfloat sdIntersection( float d1, float d2 ) { return max(d1,d2); }\n", + "global": "", "inputs": [ { "default": "0.0", "label": "", "name": "in1", - "type": "f" + "type": "sdf2d" }, { "default": "0.0", "label": "", "name": "in2", - "type": "f" + "type": "sdf2d" } ], "instance": "", "name": "sdBoolean", "outputs": [ { - "f": "sd$op($in1($uv), $in2($uv))", - "type": "f" + "sdf2d": "$op $in1($uv), $in2($uv))", + "type": "sdf2d" } ], "parameters": [ { - "default": 0, + "default": 2, "label": "", "name": "op", "type": "enum", "values": [ { "name": "Union", - "value": "Union" + "value": "min(" }, { "name": "Subtraction", - "value": "Subtraction" + "value": "max(-" }, { "name": "Intersection", - "value": "Intersection" + "value": "max(" } ] } diff --git a/addons/material_maker/nodes/sdbox.mmg b/addons/material_maker/nodes/sdbox.mmg index 05f2add..9592fdc 100644 --- a/addons/material_maker/nodes/sdbox.mmg +++ b/addons/material_maker/nodes/sdbox.mmg @@ -12,8 +12,8 @@ "w": 0.3 }, "shader_model": { - "code": "", - "global": "float sdBox(in vec2 p, in vec2 b) {\n vec2 d = abs(p)-b;\n return length(max(d,vec2(0))) + min(max(d.x,d.y),0.0);\n}\n", + "code": "vec2 $(name_uv)_d = abs($uv-0.5*vec2($cx+1.0, $cy+1.0))-vec2($w, $h);\n", + "global": "", "inputs": [ ], @@ -21,8 +21,8 @@ "name": "sdBox", "outputs": [ { - "f": "sdBox($uv-0.5*vec2($cx+1.0, $cy+1.0), vec2($w, $h))", - "type": "f" + "sdf2d": "length(max($(name_uv)_d,vec2(0)))+min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0)", + "type": "sdf2d" } ], "parameters": [ diff --git a/addons/material_maker/nodes/sdcircle.mmg b/addons/material_maker/nodes/sdcircle.mmg index c920834..e9881b5 100644 --- a/addons/material_maker/nodes/sdcircle.mmg +++ b/addons/material_maker/nodes/sdcircle.mmg @@ -7,11 +7,11 @@ "parameters": { "cx": 0, "cy": 0, - "r": 0.5 + "r": 0.25 }, "shader_model": { "code": "", - "global": "float sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n", + "global": "", "inputs": [ ], @@ -19,8 +19,8 @@ "name": "sdCircle", "outputs": [ { - "f": "sdCircle($uv-0.5*vec2($cx+1.0, $cy+1.0), $r)", - "type": "f" + "sdf2d": "length($uv-0.5*vec2($cx+1.0, $cy+1.0))-$r", + "type": "sdf2d" } ], "parameters": [ diff --git a/addons/material_maker/nodes/sdf3d_boolean.mmg b/addons/material_maker/nodes/sdf3d_boolean.mmg new file mode 100644 index 0000000..417e9ba --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_boolean.mmg @@ -0,0 +1,65 @@ +{ + "name": "sdf3d_boolean", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in1", + "type": "sdf3d" + }, + { + "default": "0.0", + "label": "", + "name": "in2", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Boolean", + "outputs": [ + { + "sdf3d": "$op $in1($uv), $in2($uv))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 1, + "label": "", + "name": "op", + "type": "enum", + "values": [ + { + "name": "Union", + "value": "min(" + }, + { + "name": "Subtraction", + "value": "max(-" + }, + { + "name": "Intersection", + "value": "max(" + } + ] + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_box.mmg b/addons/material_maker/nodes/sdf3d_box.mmg new file mode 100644 index 0000000..cd4405e --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_box.mmg @@ -0,0 +1,67 @@ +{ + "name": "sdf3d_box", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.01, + "sx": 0.25, + "sy": 0.25, + "sz": 0.5 + }, + "shader_model": { + "code": "vec3 $(name_uv)_q = abs($uv) - vec3($sx, $sy, $sz);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Box", + "outputs": [ + { + "sdf3d": "length(max($(name_uv)_q,0.0))+min(max($(name_uv)_q.x,max($(name_uv)_q.y,$(name_uv)_q.z)),0.0)-$r", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.5, + "label": "Size X", + "max": 1, + "min": 0, + "name": "sx", + "step": 0.01, + "type": "float" + }, + { + "default": 0.5, + "label": "Size Y", + "max": 1, + "min": 0, + "name": "sy", + "step": 0.01, + "type": "float" + }, + { + "default": 0.5, + "label": "Size Z", + "max": 1, + "min": 0, + "name": "sz", + "step": 0.01, + "type": "float" + }, + { + "default": 0.5, + "label": "Radius", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_capsule.mmg b/addons/material_maker/nodes/sdf3d_capsule.mmg new file mode 100644 index 0000000..e67b994 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_capsule.mmg @@ -0,0 +1,50 @@ +{ + "name": "sdf3d_capsule", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "l": 0.25, + "r": 0.1, + "sx": 0.25, + "sy": 0.25, + "sz": 0.5 + }, + "shader_model": { + "code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.y -= clamp($(name_uv)_p.y, -0.5*$l, 0.5*$l);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Capsule", + "outputs": [ + { + "sdf3d": "length($(name_uv)_p)-$r", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.5, + "label": "Length", + "max": 1, + "min": 0, + "name": "l", + "step": 0.01, + "type": "float" + }, + { + "default": 0.2, + "label": "Radius", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_circle_repeat.mmg b/addons/material_maker/nodes/sdf3d_circle_repeat.mmg new file mode 100644 index 0000000..889944a --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_circle_repeat.mmg @@ -0,0 +1,50 @@ +{ + "name": "sdf3d_circle_repeat", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "c": 4, + "r": 0.24, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 circle_repeat_transform(vec3 p, float count) {\n\tfloat r = 6.28/count;\n\tfloat pa = atan(p.x, p.y);\n\tfloat a = mod(pa+0.5*r, r)-0.5*r;\n\tvec3 rv;\n\tfloat c = cos(a-pa);\n\tfloat s = sin(a-pa);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Circle Repeat", + "outputs": [ + { + "sdf3d": "$in(circle_repeat_transform($uv, $c))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 4, + "label": "", + "max": 32, + "min": 1, + "name": "c", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_cone.mmg b/addons/material_maker/nodes/sdf3d_cone.mmg new file mode 100644 index 0000000..c706eb2 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_cone.mmg @@ -0,0 +1,41 @@ +{ + "name": "sdf3d_cone", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 30, + "r": 0, + "sx": 0.01, + "sy": 0.01, + "sz": 0.015 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Cone", + "outputs": [ + { + "sdf3d": "dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2(length($uv.xz),$uv.y))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 30, + "label": "Angle", + "max": 90, + "min": 0, + "name": "a", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_cylinder.mmg b/addons/material_maker/nodes/sdf3d_cylinder.mmg new file mode 100644 index 0000000..d26e8f1 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_cylinder.mmg @@ -0,0 +1,50 @@ +{ + "name": "sdf3d_cylinder", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "l": 0.25, + "r": 0.1, + "sx": 0.25, + "sy": 0.25, + "sz": 0.5 + }, + "shader_model": { + "code": "vec2 $(name_uv)_d = abs(vec2(length($uv.xz),$uv.y)) - vec2($r,$l);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Cylinder", + "outputs": [ + { + "sdf3d": "min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0) + length(max($(name_uv)_d,0.0))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.5, + "label": "Length", + "max": 1, + "min": 0, + "name": "l", + "step": 0.01, + "type": "float" + }, + { + "default": 0.2, + "label": "Radius", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_extrusion.mmg b/addons/material_maker/nodes/sdf3d_extrusion.mmg new file mode 100644 index 0000000..87eeac1 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_extrusion.mmg @@ -0,0 +1,47 @@ +{ + "name": "sdf3d_extrusion", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "d": 0.5, + "s": 1, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "vec2 $(name_uv)_w = vec2($in($uv.xz+vec2(0.5)),abs($uv.y)-$d);\n", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Extrusion", + "outputs": [ + { + "sdf3d": "min(max($(name_uv)_w.x,$(name_uv)_w.y),0.0)+length(max($(name_uv)_w,0.0))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.25, + "label": "", + "max": 1, + "min": 0, + "name": "d", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_repeat.mmg b/addons/material_maker/nodes/sdf3d_repeat.mmg new file mode 100644 index 0000000..3e2875c --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_repeat.mmg @@ -0,0 +1,67 @@ +{ + "name": "sdf3d_repeat", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "r": 0.24, + "rx": 4, + "ry": 4, + "s": 0.3, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 repeat(vec3 p, vec3 r, float seed, float randomness) {\n\tvec3 a = (rand3(floor(mod((p.xy+0.5*r.xy)/r.xy, 1.0/r.xy)+vec2(seed)))-0.5)*6.28*randomness;\n\tp = mod(p+0.5*r,r)-0.5*r;\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Repeat", + "outputs": [ + { + "sdf3d": "$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), $seed, $r))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 4, + "label": "X", + "max": 32, + "min": 1, + "name": "rx", + "step": 1, + "type": "float" + }, + { + "default": 4, + "label": "Y", + "max": 32, + "min": 1, + "name": "ry", + "step": 1, + "type": "float" + }, + { + "default": 0.5, + "label": "R", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_revolution.mmg b/addons/material_maker/nodes/sdf3d_revolution.mmg new file mode 100644 index 0000000..9cf93c6 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_revolution.mmg @@ -0,0 +1,47 @@ +{ + "name": "sdf3d_revolution", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "d": 0.25, + "s": 1, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "vec2 $(name_uv)_q = vec2(length($uv.xy)-$d+0.5, $uv.z+0.5);\n", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Revolution", + "outputs": [ + { + "sdf3d": "$in($(name_uv)_q)", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.25, + "label": "", + "max": 1, + "min": 0, + "name": "d", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_rotate.mmg b/addons/material_maker/nodes/sdf3d_rotate.mmg new file mode 100644 index 0000000..588e943 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_rotate.mmg @@ -0,0 +1,66 @@ +{ + "name": "sdf3d_rotate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "ax": 0, + "ay": 0, + "az": 0, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 rotate3d(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rotate", + "outputs": [ + { + "sdf3d": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 180, + "min": -180, + "name": "ax", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 180, + "min": -180, + "name": "ay", + "step": 1, + "type": "float" + }, + { + "default": 0, + "label": "Z", + "max": 180, + "min": -180, + "name": "az", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_rounded.mmg b/addons/material_maker/nodes/sdf3d_rounded.mmg new file mode 100644 index 0000000..87ce10b --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_rounded.mmg @@ -0,0 +1,49 @@ +{ + "name": "sdf3d_rounded", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.15, + "op": 0, + "r": 0.05, + "w": 0.28 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Rounded", + "outputs": [ + { + "sdf3d": "$in($uv)-$r", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_scale.mmg b/addons/material_maker/nodes/sdf3d_scale.mmg new file mode 100644 index 0000000..0ee47bf --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_scale.mmg @@ -0,0 +1,46 @@ +{ + "name": "sdf3d_scale", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "s": 1, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Scale", + "outputs": [ + { + "sdf3d": "$in(($uv)/$s)*$s", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 1, + "label": "", + "max": 5, + "min": 0, + "name": "s", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_smoothboolean.mmg b/addons/material_maker/nodes/sdf3d_smoothboolean.mmg new file mode 100644 index 0000000..ff3ac8a --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_smoothboolean.mmg @@ -0,0 +1,75 @@ +{ + "name": "sdf3d_smoothboolean", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.1, + "op": 0, + "r": 0.3, + "w": 0.28 + }, + "shader_model": { + "code": "", + "global": "float sdf3SmoothUnion(float d1, float d2, float k) {\n float h = clamp(0.5+0.5*(d2-d1)/k, 0.0, 1.0);\n return mix(d2, d1, h)-k*h*(1.0-h);\n}\n\nfloat sdf3SmoothSubtraction( float d1, float d2, float k ) {\n float h = clamp(0.5-0.5*(d2+d1)/k, 0.0, 1.0);\n return mix( d2, -d1, h )+k*h*(1.0-h);\n}\n\nfloat sdf3SmoothIntersection( float d1, float d2, float k ) {\n float h = clamp(0.5-0.5*(d2-d1)/k, 0.0, 1.0);\n return mix(d2, d1, h)+k*h*(1.0-h);\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in1", + "type": "sdf3d" + }, + { + "default": "0.0", + "label": "", + "name": "in2", + "type": "sdf3d" + } + ], + "instance": "", + "name": "sdSmoothBoolean", + "outputs": [ + { + "sdf3d": "sdf3Smooth$op($in1($uv), $in2($uv), $k)", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "name": "op", + "type": "enum", + "values": [ + { + "name": "Union", + "value": "Union" + }, + { + "name": "Subtraction", + "value": "Subtraction" + }, + { + "name": "Intersection", + "value": "Intersection" + } + ] + }, + { + "default": 0, + "label": "", + "max": 1, + "min": 0, + "name": "k", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_sphere.mmg b/addons/material_maker/nodes/sdf3d_sphere.mmg new file mode 100644 index 0000000..06891a1 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_sphere.mmg @@ -0,0 +1,37 @@ +{ + "name": "sdf3d_sphere", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.5 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Sphere", + "outputs": [ + { + "sdf3d": "length($uv)-$r", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.5, + "label": "", + "max": 1, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_torus.mmg b/addons/material_maker/nodes/sdf3d_torus.mmg new file mode 100644 index 0000000..60022c1 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_torus.mmg @@ -0,0 +1,50 @@ +{ + "name": "sdf3d_torus", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "R": 0.25, + "r": 0.1, + "sx": 0.1, + "sy": 0.1, + "sz": 0.02 + }, + "shader_model": { + "code": "vec2 $(name_uv)_q = vec2(length($uv.xy)-$R,$uv.z);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Torus", + "outputs": [ + { + "sdf3d": "length($(name_uv)_q)-$r", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0.5, + "label": "R", + "max": 1, + "min": 0, + "name": "R", + "step": 0.01, + "type": "float" + }, + { + "default": 0.1, + "label": "r", + "max": 0.5, + "min": 0, + "name": "r", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdf3d_translate.mmg b/addons/material_maker/nodes/sdf3d_translate.mmg new file mode 100644 index 0000000..7a7f167 --- /dev/null +++ b/addons/material_maker/nodes/sdf3d_translate.mmg @@ -0,0 +1,62 @@ +{ + "name": "sdf3d_translate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "x": 0, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf3d" + } + ], + "instance": "", + "name": "Translate", + "outputs": [ + { + "sdf3d": "$in($uv-vec3($x, $y, $z))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 1, + "min": -1, + "name": "x", + "step": 0.01, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 1, + "min": -1, + "name": "y", + "step": 0.01, + "type": "float" + }, + { + "default": 0, + "label": "Z", + "max": 1, + "min": -1, + "name": "z", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdline.mmg b/addons/material_maker/nodes/sdline.mmg index 8aaf418..763df54 100644 --- a/addons/material_maker/nodes/sdline.mmg +++ b/addons/material_maker/nodes/sdline.mmg @@ -25,8 +25,8 @@ "name": "sdLine", "outputs": [ { - "f": "sdLine($uv, vec2($ax, $ay), vec2($bx, $by))", - "type": "f" + "sdf2d": "sdLine($uv, vec2($ax, $ay), vec2($bx, $by))", + "type": "sdf2d" } ], "parameters": [ diff --git a/addons/material_maker/nodes/sdrhombus.mmg b/addons/material_maker/nodes/sdrhombus.mmg index e0be88f..02925e1 100644 --- a/addons/material_maker/nodes/sdrhombus.mmg +++ b/addons/material_maker/nodes/sdrhombus.mmg @@ -9,7 +9,7 @@ "cy": 0, "h": 0.2, "r": 0.3, - "w": 0.3 + "w": 0.5 }, "shader_model": { "code": "", @@ -21,8 +21,8 @@ "name": "sdRhombus", "outputs": [ { - "f": "sdRhombus($uv-0.5*vec2($cx+1.0, $cy+1.0), vec2($w, $h))", - "type": "f" + "sdf2d": "sdRhombus($uv-0.5*vec2($cx+1.0, $cy+1.0), vec2($w, $h))", + "type": "sdf2d" } ], "parameters": [ diff --git a/addons/material_maker/nodes/sdrotate.mmg b/addons/material_maker/nodes/sdrotate.mmg new file mode 100644 index 0000000..fefaaab --- /dev/null +++ b/addons/material_maker/nodes/sdrotate.mmg @@ -0,0 +1,45 @@ +{ + "name": "sdrotate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "vec2 sdf2d_rotate(vec2 uv, float a) {\n\tvec2 rv;\n\tfloat c = cos(a);\n\tfloat s = sin(a);\n\tuv -= vec2(0.5);\n\trv.x = uv.x*c+uv.y*s;\n\trv.y = -uv.x*s+uv.y*c;\n\treturn rv+vec2(0.5);\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Rotate", + "outputs": [ + { + "sdf2d": "$in(sdf2d_rotate($uv, $a*0.01745329251))", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "max": 180, + "min": -180, + "name": "a", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdroundedshape.mmg b/addons/material_maker/nodes/sdroundedshape.mmg index 9557c06..80305a4 100644 --- a/addons/material_maker/nodes/sdroundedshape.mmg +++ b/addons/material_maker/nodes/sdroundedshape.mmg @@ -11,26 +11,26 @@ "h": 0.08, "k": 0.15, "op": 0, - "r": 0.2, + "r": 0.1, "w": 0.28 }, "shader_model": { "code": "", - "global": "float sdSmoothUnion( float d1, float d2, float k ) {\n float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 );\n return mix( d2, d1, h ) - k*h*(1.0-h); }\n\nfloat sdSmoothSubtraction( float d1, float d2, float k ) {\n float h = clamp( 0.5 - 0.5*(d2+d1)/k, 0.0, 1.0 );\n return mix( d2, -d1, h ) + k*h*(1.0-h); }\n\nfloat sdSmoothIntersection( float d1, float d2, float k ) {\n float h = clamp( 0.5 - 0.5*(d2-d1)/k, 0.0, 1.0 );\n return mix( d2, d1, h ) + k*h*(1.0-h); }\n", + "global": "", "inputs": [ { "default": "0.0", "label": "", "name": "in", - "type": "f" + "type": "sdf2d" } ], "instance": "", "name": "sdRoundedShape", "outputs": [ { - "f": "$in($uv) - $r", - "type": "f" + "sdf2d": "$in($uv)-$r", + "type": "sdf2d" } ], "parameters": [ diff --git a/addons/material_maker/nodes/sdscale.mmg b/addons/material_maker/nodes/sdscale.mmg new file mode 100644 index 0000000..0b5c875 --- /dev/null +++ b/addons/material_maker/nodes/sdscale.mmg @@ -0,0 +1,46 @@ +{ + "name": "sdscale", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "s": 2.21, + "x": 0.35, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Scale", + "outputs": [ + { + "sdf2d": "$in(($uv-vec2(0.5))/$s+vec2(0.5))*$s", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": 1, + "label": "", + "max": 5, + "min": 0, + "name": "s", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdshow.mmg b/addons/material_maker/nodes/sdshow.mmg new file mode 100644 index 0000000..2692660 --- /dev/null +++ b/addons/material_maker/nodes/sdshow.mmg @@ -0,0 +1,47 @@ +{ + "name": "sdshow", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0.1, + "cx": 0, + "cy": 0, + "h": 0.08, + "r": 0.3, + "w": 0.28 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "sdShow", + "outputs": [ + { + "f": "clamp(-$in($uv)/max($bevel, 0.00001), 0.0, 1.0)", + "type": "f" + } + ], + "parameters": [ + { + "default": 0, + "label": "Bevel", + "max": 1, + "min": 0, + "name": "bevel", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/sdsmoothboolean.mmg b/addons/material_maker/nodes/sdsmoothboolean.mmg index ac436a9..e52e09c 100644 --- a/addons/material_maker/nodes/sdsmoothboolean.mmg +++ b/addons/material_maker/nodes/sdsmoothboolean.mmg @@ -22,21 +22,21 @@ "default": "0.0", "label": "", "name": "in1", - "type": "f" + "type": "sdf2d" }, { "default": "0.0", "label": "", "name": "in2", - "type": "f" + "type": "sdf2d" } ], "instance": "", "name": "sdSmoothBoolean", "outputs": [ { - "f": "sdSmooth$op($in1($uv), $in2($uv), $k)", - "type": "f" + "sdf2d": "sdSmooth$op($in1($uv), $in2($uv), $k)", + "type": "sdf2d" } ], "parameters": [ diff --git a/addons/material_maker/nodes/sdtranslate.mmg b/addons/material_maker/nodes/sdtranslate.mmg new file mode 100644 index 0000000..a4b72f7 --- /dev/null +++ b/addons/material_maker/nodes/sdtranslate.mmg @@ -0,0 +1,53 @@ +{ + "name": "sdtranslate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "x": 0, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "Translate", + "outputs": [ + { + "sdf2d": "$in($uv-vec2($x, $y))", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": 0, + "label": "X", + "max": 1, + "min": -1, + "name": "x", + "step": 0.01, + "type": "float" + }, + { + "default": 0, + "label": "Y", + "max": 1, + "min": -1, + "name": "y", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/addons/material_maker/nodes/switch.gd b/addons/material_maker/nodes/switch.gd index 20626a6..ce1561e 100644 --- a/addons/material_maker/nodes/switch.gd +++ b/addons/material_maker/nodes/switch.gd @@ -69,7 +69,9 @@ func update_node() -> void: var space = Control.new() space.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL sizer.add_child(space) - sizer.add_child(preload("res://addons/material_maker/widgets/preview_button.tscn").instance()) + var button = preload("res://addons/material_maker/widgets/preview_button.tscn").instance() + sizer.add_child(button) + button.connect("toggled", self, "on_preview_button", [ get_child_count()-1 ]) add_child(sizer) rect_size = Vector2(0, 0) for i in range(get_child_count()): @@ -79,13 +81,12 @@ func update_node() -> void: if i < 5: has_output = i < output_count sizer.get_child(sizer.get_child_count()-1).visible = has_output - sizer.get_child(sizer.get_child_count()-1).connect("toggled", self, "on_preview_button", [ i ]) if i >= input_count: sizer.get_child(0).text = "" has_input = false else: sizer.get_child(0).text = PoolByteArray([65+i%int(output_count)]).get_string_from_ascii()+str(1+i/int(output_count)) sizer.get_child(0).add_color_override("font_color", Color(1.0, 1.0, 1.0) if i/int(output_count) == generator.parameters.source else Color(0.5, 0.5, 0.5)) - set_slot(i, has_input, 0, Color(0.0, 0.5, 0.0, 0.5), has_output, 0, Color(0.0, 0.5, 0.0, 0.5)) + set_slot(i, has_input, 42, Color(1.0, 1.0, 1.0, 1.0), has_output, 42, Color(1.0, 1.0, 1.0, 1.0)) # Preview restore_preview_widget() diff --git a/addons/material_maker/widgets/node_editor/input.gd b/addons/material_maker/widgets/node_editor/input.gd index 301f98d..313461b 100644 --- a/addons/material_maker/widgets/node_editor/input.gd +++ b/addons/material_maker/widgets/node_editor/input.gd @@ -15,9 +15,14 @@ func set_model_data(data) -> void: $Type.selected = 1 elif data.type == "rgba": $Type.selected = 2 + elif data.type == "sdf2d": + $Type.selected = 3 + elif data.type == "sdf3d": + $Type.selected = 4 else: $Type.selected = 0 $Default.text = data.default + $Function.pressed = data.has("function") and data.function func get_model_data() -> Dictionary: var data = { name=$Name.text, label=$Label.text, default=$Default.text } @@ -25,8 +30,14 @@ func get_model_data() -> Dictionary: data.type = "rgb" elif $Type.selected == 2: data.type = "rgba" + elif $Type.selected == 3: + data.type = "sdf2d" + elif $Type.selected == 4: + data.type = "sdf3d" else: data.type = "f" + if $Function.pressed: + data.function = true return data func _on_Delete_pressed() -> void: diff --git a/addons/material_maker/widgets/node_editor/input.tscn b/addons/material_maker/widgets/node_editor/input.tscn index a56a889..3a22a47 100644 --- a/addons/material_maker/widgets/node_editor/input.tscn +++ b/addons/material_maker/widgets/node_editor/input.tscn @@ -66,7 +66,7 @@ margin_bottom = 24.0 rect_min_size = Vector2( 102, 0 ) hint_tooltip = "Input flag" text = "GreyScale" -items = [ "GreyScale", null, false, 0, null, "Color", null, false, 1, null, "RGBA", null, false, -1, null ] +items = [ "GreyScale", null, false, 0, null, "Color", null, false, 1, null, "RGBA", null, false, 2, null, "SDF2D", null, false, 3, null, "SDF3D", null, false, 4, null ] selected = 0 [node name="Default" type="LineEdit" parent="."] @@ -77,6 +77,12 @@ rect_min_size = Vector2( 70, 0 ) hint_tooltip = "Default value" size_flags_horizontal = 3 text = "0.0" + +[node name="Function" type="CheckBox" parent="."] +margin_left = 418.0 +margin_right = 501.0 +margin_bottom = 24.0 +text = "Function" [connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"] [connection signal="pressed" from="Up" to="." method="_on_Up_pressed"] [connection signal="pressed" from="Down" to="." method="_on_Down_pressed"] diff --git a/addons/material_maker/widgets/node_editor/output.gd b/addons/material_maker/widgets/node_editor/output.gd index ca9d8c0..4af81ab 100644 --- a/addons/material_maker/widgets/node_editor/output.gd +++ b/addons/material_maker/widgets/node_editor/output.gd @@ -15,6 +15,12 @@ func set_model_data(data) -> void: elif data.has("rgba"): $Type.selected = 2 $Value.text = data.rgba + elif data.has("sdf2d"): + $Type.selected = 3 + $Value.text = data.sdf2d + elif data.has("sdf3d"): + $Type.selected = 4 + $Value.text = data.sdf3d elif data.has("f"): $Type.selected = 0 $Value.text = data.f @@ -24,6 +30,10 @@ func get_model_data() -> Dictionary: return { rgb=$Value.text } elif $Type.selected == 2: return { rgba=$Value.text } + elif $Type.selected == 3: + return { sdf2d=$Value.text } + elif $Type.selected == 4: + return { sdf3d=$Value.text } else: return { f=$Value.text } diff --git a/addons/material_maker/widgets/node_editor/output.tscn b/addons/material_maker/widgets/node_editor/output.tscn index bd1d127..17e0e77 100644 --- a/addons/material_maker/widgets/node_editor/output.tscn +++ b/addons/material_maker/widgets/node_editor/output.tscn @@ -58,7 +58,7 @@ margin_bottom = 25.0 rect_min_size = Vector2( 102, 0 ) hint_tooltip = "Input flag" text = "GreyScale" -items = [ "GreyScale", null, false, 0, null, "Color", null, false, 1, null, "RGBA", null, false, -1, null ] +items = [ "GreyScale", null, false, 0, null, "Color", null, false, 1, null, "RGBA", null, false, 2, null, "SDF2D", null, false, 3, null, "SDF3D", null, false, 4, null ] selected = 0 [node name="Value" type="LineEdit" parent="."]