From fe2c83a79a08bf3bc4c9973c03f71a91a0dc8d00 Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Sat, 4 Apr 2020 07:16:45 +0200 Subject: [PATCH] Added Axis parameter to 3D primitives --- addons/material_maker/nodes/sdf3d_capsule.mmg | 28 ++++++++++--- addons/material_maker/nodes/sdf3d_cone.mmg | 40 ++++++++++++++++--- .../material_maker/nodes/sdf3d_cylinder.mmg | 30 +++++++++++--- addons/material_maker/nodes/sdf3d_torus.mmg | 28 ++++++++++--- 4 files changed, 105 insertions(+), 21 deletions(-) diff --git a/addons/material_maker/nodes/sdf3d_capsule.mmg b/addons/material_maker/nodes/sdf3d_capsule.mmg index 814585b..3ed3816 100644 --- a/addons/material_maker/nodes/sdf3d_capsule.mmg +++ b/addons/material_maker/nodes/sdf3d_capsule.mmg @@ -5,14 +5,12 @@ "y": 0 }, "parameters": { + "axis": 1, "l": 0.3, - "r": 0.15, - "sx": 0.25, - "sy": 0.25, - "sz": 0.5 + "r": 0.2 }, "shader_model": { - "code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.y -= clamp($(name_uv)_p.y, -$l, $l);\n", + "code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);\n", "global": "", "inputs": [ @@ -26,6 +24,26 @@ } ], "parameters": [ + { + "default": 1, + "label": "Axis", + "name": "axis", + "type": "enum", + "values": [ + { + "name": "X", + "value": "x" + }, + { + "name": "Y", + "value": "y" + }, + { + "name": "Z", + "value": "z" + } + ] + }, { "control": "Rect1.y", "default": 0.25, diff --git a/addons/material_maker/nodes/sdf3d_cone.mmg b/addons/material_maker/nodes/sdf3d_cone.mmg index c706eb2..b52f73b 100644 --- a/addons/material_maker/nodes/sdf3d_cone.mmg +++ b/addons/material_maker/nodes/sdf3d_cone.mmg @@ -6,10 +6,7 @@ }, "parameters": { "a": 30, - "r": 0, - "sx": 0.01, - "sy": 0.01, - "sz": 0.015 + "axis": 2 }, "shader_model": { "code": "", @@ -21,12 +18,45 @@ "name": "Cone", "outputs": [ { - "sdf3d": "dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2(length($uv.xz),$uv.y))", + "sdf3d": "dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))", "type": "sdf3d" } ], "parameters": [ { + "default": 5, + "label": "Axis", + "name": "axis", + "type": "enum", + "values": [ + { + "name": "+X", + "value": "length($uv.yz),-$uv.x" + }, + { + "name": "-X", + "value": "length($uv.yz),$uv.x" + }, + { + "name": "+Y", + "value": "length($uv.xz),$uv.y" + }, + { + "name": "-Y", + "value": "length($uv.xz),-$uv.y" + }, + { + "name": "+Z", + "value": "length($uv.xy),-$uv.z" + }, + { + "name": "-Z", + "value": "length($uv.xy),$uv.z" + } + ] + }, + { + "control": "None", "default": 30, "label": "Angle", "max": 90, diff --git a/addons/material_maker/nodes/sdf3d_cylinder.mmg b/addons/material_maker/nodes/sdf3d_cylinder.mmg index 34a7877..d276144 100644 --- a/addons/material_maker/nodes/sdf3d_cylinder.mmg +++ b/addons/material_maker/nodes/sdf3d_cylinder.mmg @@ -5,14 +5,12 @@ "y": 0 }, "parameters": { - "l": 0.4, - "r": 0.2, - "sx": 0.25, - "sy": 0.25, - "sz": 0.5 + "axis": 1, + "l": 0.25, + "r": 0.25 }, "shader_model": { - "code": "vec2 $(name_uv)_d = abs(vec2(length($uv.xz),$uv.y)) - vec2($r,$l);\n", + "code": "vec2 $(name_uv)_d = abs(vec2($axis)) - vec2($r,$l);\n", "global": "", "inputs": [ @@ -26,6 +24,26 @@ } ], "parameters": [ + { + "default": 1, + "label": "Axis", + "name": "axis", + "type": "enum", + "values": [ + { + "name": "X", + "value": "length($uv.yz),$uv.x" + }, + { + "name": "Y", + "value": "length($uv.xz),$uv.y" + }, + { + "name": "Z", + "value": "length($uv.xy),$uv.z" + } + ] + }, { "control": "Rect1.y", "default": 0.5, diff --git a/addons/material_maker/nodes/sdf3d_torus.mmg b/addons/material_maker/nodes/sdf3d_torus.mmg index 4397002..c1eeabb 100644 --- a/addons/material_maker/nodes/sdf3d_torus.mmg +++ b/addons/material_maker/nodes/sdf3d_torus.mmg @@ -6,13 +6,11 @@ }, "parameters": { "R": 0.3, - "r": 0.1, - "sx": 0.1, - "sy": 0.1, - "sz": 0.02 + "axis": 2, + "r": 0.15 }, "shader_model": { - "code": "vec2 $(name_uv)_q = vec2(length($uv.xy)-$R,$uv.z);\n", + "code": "vec2 $(name_uv)_q = vec2($axis);\n", "global": "", "inputs": [ @@ -26,6 +24,26 @@ } ], "parameters": [ + { + "default": 0, + "label": "Axis", + "name": "axis", + "type": "enum", + "values": [ + { + "name": "X", + "value": "length($uv.yz)-$R,$uv.x" + }, + { + "name": "Y", + "value": "length($uv.zx)-$R,$uv.y" + }, + { + "name": "Z", + "value": "length($uv.xy)-$R,$uv.z" + } + ] + }, { "control": "Radius1.r", "default": 0.5,