From d80e3caeb99a6f48c8ab01b89fee1f3f47ed839f Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Sat, 21 Dec 2019 21:49:16 +0100 Subject: [PATCH] Added 2d arc node (also useful to create torus arcs) --- addons/material_maker/nodes/sdarc.mmg | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 addons/material_maker/nodes/sdarc.mmg 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