From 78891affaefaf11892f63f7c848aae175f33af0b Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Wed, 18 Dec 2019 23:18:28 +0100 Subject: [PATCH] Added capsule and cylinder --- .../material_maker/examples/raymarching.ptex | 2122 +---------------- addons/material_maker/nodes/sdf3d_capsule.mmg | 50 + .../material_maker/nodes/sdf3d_cylinder.mmg | 50 + 3 files changed, 125 insertions(+), 2097 deletions(-) create mode 100644 addons/material_maker/nodes/sdf3d_capsule.mmg create mode 100644 addons/material_maker/nodes/sdf3d_cylinder.mmg diff --git a/addons/material_maker/examples/raymarching.ptex b/addons/material_maker/examples/raymarching.ptex index 0ce6dc4..4d20255 100644 --- a/addons/material_maker/examples/raymarching.ptex +++ b/addons/material_maker/examples/raymarching.ptex @@ -1,89 +1,5 @@ { "connections": [ - { - "from": "perlin", - "from_port": 0, - "to": "colorize", - "to_port": 0 - }, - { - "from": "colorize", - "from_port": 0, - "to": "Material", - "to_port": 2 - }, - { - "from": "sdf3d_box", - "from_port": 0, - "to": "sdf3d_smoothboolean", - "to_port": 1 - }, - { - "from": "sdf3d_smoothboolean", - "from_port": 0, - "to": "sdf3d_smoothboolean_2", - "to_port": 1 - }, - { - "from": "sdf3d_smoothboolean_2", - "from_port": 0, - "to": "_3", - "to_port": 0 - }, - { - "from": "sdf3d_torus", - "from_port": 0, - "to": "sdf3d_translate", - "to_port": 0 - }, - { - "from": "sdf3d_translate", - "from_port": 0, - "to": "sdf3d_smoothboolean_2", - "to_port": 0 - }, - { - "from": "sdf3d_sphere", - "from_port": 0, - "to": "sdf3d_translate_2", - "to_port": 0 - }, - { - "from": "sdf3d_translate_2", - "from_port": 0, - "to": "sdf3d_boolean", - "to_port": 0 - }, - { - "from": "sdf3d_sphere", - "from_port": 0, - "to": "sdf3d_translate_2_2", - "to_port": 0 - }, - { - "from": "sdf3d_translate_2_2", - "from_port": 0, - "to": "sdf3d_boolean", - "to_port": 1 - }, - { - "from": "sdf3d_boolean", - "from_port": 0, - "to": "sdf3d_translate_3", - "to_port": 0 - }, - { - "from": "sdf3d_translate_3", - "from_port": 0, - "to": "sdf3d_smoothboolean", - "to_port": 0 - }, - { - "from": "sdf3d_smoothboolean_2", - "from_port": 0, - "to": "sdscale", - "to_port": 0 - }, { "from": "sdbox", "from_port": 0, @@ -115,208 +31,28 @@ "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": "_3_2", - "from_port": 0, - "to": "colorize_3", - "to_port": 0 - }, - { - "from": "graph", - "from_port": 0, - "to": "sdf3d_scale", - "to_port": 0 - }, - { - "from": "_3_2", - "from_port": 0, - "to": "occlusion", - "to_port": 0 - }, - { - "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": "_3_2", - "from_port": 0, - "to": "colorize_5", - "to_port": 0 - }, - { - "from": "colorize_2", - "from_port": 0, - "to": "blend", - "to_port": 0 - }, - { - "from": "colorize_5", - "from_port": 0, - "to": "blend", - "to_port": 2 - }, - { - "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, + "from": "raymarching", + "from_port": 1, "to": "Material", "to_port": 4 }, { - "from": "perlin", + "from": "sdrotate", "from_port": 0, - "to": "normal_map", + "to": "raymarching", "to_port": 0 }, { - "from": "_3_2", - "from_port": 1, - "to": "blend_2", + "from": "uniform", + "from_port": 0, + "to": "Material", "to_port": 0 }, { - "from": "normal_map", + "from": "uniform", "from_port": 0, - "to": "blend_2", + "to": "Material", "to_port": 1 - }, - { - "from": "colorize_5_2", - "from_port": 0, - "to": "blend_2", - "to_port": 2 - }, - { - "from": "_3_2", - "from_port": 0, - "to": "colorize_5_2", - "to_port": 0 } ], "label": "Graph", @@ -329,8 +65,8 @@ { "name": "Material", "node_position": { - "x": 463, - "y": 1358 + "x": -336, + "y": 266 }, "parameters": { "albedo_color": { @@ -351,388 +87,6 @@ }, "type": "material" }, - { - "name": "_3", - "node_position": { - "x": -563.5, - "y": -507 - }, - "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": "perlin", - "node_position": { - "x": -385.399658, - "y": 1196.349854 - }, - "parameters": { - "iterations": 7, - "persistence": 0.75, - "scale_x": 4, - "scale_y": 4 - }, - "type": "perlin" - }, - { - "name": "colorize", - "node_position": { - "x": -367.399658, - "y": 1344.349976 - }, - "parameters": { - "gradient": { - "interpolation": 1, - "points": [ - { - "a": 1, - "b": 0.171875, - "g": 0.171875, - "pos": 0.1, - "r": 0.171875 - }, - { - "a": 1, - "b": 1, - "g": 1, - "pos": 1, - "r": 1 - } - ], - "type": "Gradient" - } - }, - "type": "colorize" - }, - { - "name": "sdf3d_boolean", - "node_position": { - "x": -985.049805, - "y": -699.10498 - }, - "parameters": { - "bevel": 0, - "cx": 0, - "cy": 0, - "h": 0.08, - "op": 0, - "r": 0.3, - "w": 0.28 - }, - "type": "sdf3d_boolean" - }, - { - "name": "sdf3d_box", - "node_position": { - "x": -1189.376221, - "y": -426.60495 - }, - "parameters": { - "r": 0.26, - "sx": 0.1, - "sy": 0.1, - "sz": 0.02 - }, - "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" - }, - { - "name": "sdf3d_torus", - "node_position": { - "x": -981.376282, - "y": -453.60495 - }, - "parameters": { - "R": 0.38, - "a1": 0.5, - "a2": 0.865, - "r": 0.03, - "sx": 0.1, - "sy": 0.1, - "sz": 0.02 - }, - "shader_model": { - "code": "\n", - "global": "float sdf3CappedTorus(vec3 p, float R, float r, vec2 sc) {\n\tp.x = abs(p.x);\n\tfloat k = (sc.y*p.x>sc.x*p.y)?dot(p.xy,sc):length(p.xy);\n\treturn sqrt(dot(p,p)+R*R-2.0*R*k)-r;\n}\n", - "inputs": [ - - ], - "instance": "", - "name": "Capped Torus", - "outputs": [ - { - "sdf3d": "sdf3CappedTorus($uv, $R, $r, vec2($a1, $a2))", - "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" - }, - { - "default": 0.5, - "label": "A1", - "max": 1, - "min": 0, - "name": "a1", - "step": 0.01, - "type": "float" - }, - { - "default": 0.5, - "label": "A2", - "max": 1, - "min": 0, - "name": "a2", - "step": 0.01, - "type": "float" - } - ] - }, - "type": "shader" - }, - { - "name": "sdf3d_smoothboolean", - "node_position": { - "x": -986.049805, - "y": -523.10498 - }, - "parameters": { - "bevel": 0, - "cx": 0, - "cy": 0, - "h": 0.08, - "k": 0.02, - "op": 1, - "r": 0.3, - "w": 0.28 - }, - "type": "sdf3d_smoothboolean" - }, - { - "name": "sdf3d_smoothboolean_2", - "node_position": { - "x": -758.569458, - "y": -341.337097 - }, - "parameters": { - "bevel": 0, - "cx": 0, - "cy": 0, - "h": 0.08, - "k": 0.04, - "op": 1, - "r": 0.3, - "w": 0.28 - }, - "type": "sdf3d_smoothboolean" - }, - { - "name": "sdf3d_sphere", - "node_position": { - "x": -1164.049805, - "y": -693.10498 - }, - "parameters": { - "r": 0.07 - }, - "type": "sdf3d_sphere" - }, - { - "name": "sdf3d_translate", - "node_position": { - "x": -977.057617, - "y": -329.090332 - }, - "parameters": { - "x": 0, - "y": -0.19, - "z": 0.23 - }, - "type": "sdf3d_translate" - }, - { - "name": "sdf3d_translate_2", - "node_position": { - "x": -1172.057617, - "y": -640.590332 - }, - "parameters": { - "x": 0.17, - "y": 0, - "z": 0 - }, - "type": "sdf3d_translate" - }, - { - "name": "sdf3d_translate_2_2", - "node_position": { - "x": -1171.057617, - "y": -537.090332 - }, - "parameters": { - "x": -0.17, - "y": 0, - "z": 0 - }, - "type": "sdf3d_translate" - }, - { - "name": "sdf3d_translate_3", - "node_position": { - "x": -983.057617, - "y": -640.340332 - }, - "parameters": { - "x": 0, - "y": -0.12, - "z": 0.23 - }, - "type": "sdf3d_translate" - }, - { - "name": "sdscale", - "node_position": { - "x": -972.057617, - "y": -229.090332 - }, - "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" - }, { "name": "sdrotate", "node_position": { @@ -952,45 +306,6 @@ }, "type": "shader" }, - { - "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": "sdf3d_revolution", "node_position": { @@ -1039,1419 +354,32 @@ "type": "shader" }, { - "connections": [ - { - "from": "sdcircle", - "from_port": 0, - "to": "sdf3d_extrusion", - "to_port": 0 - }, - { - "from": "sdf3d_sphere_2", - "from_port": 0, - "to": "sdf3d_translate_4", - "to_port": 0 - }, - { - "from": "sdf3d_extrusion", - "from_port": 0, - "to": "sdf3d_translate_4_2", - "to_port": 0 - }, - { - "from": "sdf3d_translate_4", - "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_extrusion", - "from_port": 0, - "to": "sdf3d_scale", - "to_port": 0 - }, - { - "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_translate_4_3_3", - "from_port": 0, - "to": "gen_outputs", - "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_rotate_2_2", - "from_port": 0, - "to": "sdf3d_translate_4_3_2_2_2", - "to_port": 0 - }, - { - "from": "sdf3d_box_2", - "from_port": 0, - "to": "sdf3d_rotate_2_2", - "to_port": 0 - }, - { - "from": "sdf3d_translate_4_3_2_2_2", - "from_port": 0, - "to": "sdf3d_repeat", - "to_port": 0 - }, - { - "from": "sdf3d_repeat", - "from_port": 0, - "to": "sdf3d_rotate_2_2_2", - "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_translate_4_3_2_2_2_2", - "from_port": 0, - "to": "sdf3d_boolean", - "to_port": 0 - }, - { - "from": "sdf3d_smoothboolean_3_2_3_2", - "from_port": 0, - "to": "sdf3d_boolean", - "to_port": 1 - }, - { - "from": "sdf3d_boolean", - "from_port": 0, - "to": "sdf3d_translate_4_3_3", - "to_port": 0 - } - ], - "label": "Skull", - "name": "graph", + "name": "raymarching", "node_position": { - "x": -972.86731, - "y": 1204.615234 + "x": -522.23468, + "y": 348.748474 }, - "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.1, - "op": 0, - "r": 0.3, - "w": 0.28 - }, - "type": "sdf3d_smoothboolean" - }, - { - "name": "sdf3d_translate_4", - "node_position": { - "x": -1044.989258, - "y": 830.422729 - }, - "parameters": { - "x": 0, - "y": 0, - "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": -1040.989258, - "y": 776.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": -32, - "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.21 - }, - "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_extrusion", - "node_position": { - "x": -1043.989258, - "y": 1045.922729 - }, - "parameters": { - "a": 0, - "d": 0.08, - "s": 1, - "x": 0.35, - "y": 0, - "z": 0 - }, - "type": "sdf3d_extrusion" - }, - { - "name": "sdf3d_smoothboolean_3_2_3_2", - "node_position": { - "x": -638.693726, - "y": 1561.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": "sdcircle", - "node_position": { - "x": -1075.989258, - "y": 940.422729 - }, - "parameters": { - "cx": 0, - "cy": 0, - "r": 0.16 - }, - "type": "sdcircle" - }, - { - "name": "sdf3d_translate_4_2", - "node_position": { - "x": -1052.989258, - "y": 1102.922729 - }, - "parameters": { - "x": 0, - "y": 0.21, - "z": 0.08 - }, - "type": "sdf3d_translate" - }, - { - "name": "sdf3d_translate_4_3_3", - "node_position": { - "x": -200.318359, - "y": 1531.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": -146.318359, - "y": 1121.935181 - }, - "parameters": { - - }, - "ports": [ - { - "name": "port0", - "type": "rgba" - } - ], - "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": -830.482544, - "y": 1793.119385 - }, - "parameters": { - "x": 0, - "y": 0.233, - "z": 0 - }, - "type": "sdf3d_translate" - }, - { - "name": "sdf3d_rotate_2_2", - "node_position": { - "x": -835.482544, - "y": 1692.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": -830.482544, - "y": 1898.119385 - }, - "parameters": { - "a": 0, - "c": 22, - "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": -634.235718, - "y": 1649.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": -631.235718, - "y": 1757.869385 - }, - "parameters": { - "x": 0, - "y": 0.3, - "z": 0.07 - }, - "type": "sdf3d_translate" - }, - { - "name": "sdf3d_boolean", - "node_position": { - "x": -424.235718, - "y": 1607.369385 - }, - "parameters": { - "bevel": 0, - "cx": 0, - "cy": 0, - "h": 0.08, - "op": 1, - "r": 0.3, - "w": 0.28 - }, - "type": "sdf3d_boolean" - } - ], "parameters": { }, - "type": "graph" + "type": "raymarching" }, { - "name": "colorize_2", + "name": "uniform", "node_position": { - "x": -126.553131, - "y": 1179.272949 + "x": -576.760742, + "y": 211.755493 }, "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" + "color": { + "a": 1, + "b": 1, + "g": 0.415686, + "r": 0, + "type": "Color" } }, - "type": "colorize" - }, - { - "name": "uniform_greyscale", - "node_position": { - "x": 114.446899, - "y": 1316.272949 - }, - "parameters": { - "color": 0 - }, - "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.33, - "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.35, - "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.35, - "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.35, - "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.027452, - "g": 0.047034, - "pos": 0, - "r": 0.057292 - }, - { - "a": 1, - "b": 0.003581, - "g": 0.076426, - "pos": 1, - "r": 0.114583 - } - ], - "type": "Gradient" - } - }, - "type": "colorize" - }, - { - "name": "colorize_5", - "node_position": { - "x": -131.127869, - "y": 1320.013184 - }, - "parameters": { - "gradient": { - "interpolation": 1, - "points": [ - { - "a": 1, - "b": 0, - "g": 0, - "pos": 0, - "r": 0 - }, - { - "a": 1, - "b": 1, - "g": 1, - "pos": 0.063636, - "r": 1 - } - ], - "type": "Gradient" - } - }, - "type": "colorize" - }, - { - "name": "blend", - "node_position": { - "x": 78.872131, - "y": 1216.013184 - }, - "parameters": { - "amount": 0.5, - "blend_type": 0 - }, - "type": "blend" - }, - { - "name": "sdf3d_repeat_2", - "node_position": { - "x": -928.880676, - "y": 1590.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": -978.480713, - "y": 1472.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": -757.380676, - "y": 1593.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": -752.880676, - "y": 1509.931152 - }, - "parameters": { - "bevel": 0, - "cx": 0, - "cy": 0, - "h": 0.08, - "k": 0.01, - "op": 0, - "r": 0.3, - "w": 0.28 - }, - "type": "sdf3d_smoothboolean" - }, - { - "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": "rgba" - } - ], - "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": -923.764893, - "y": 1534.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": -933.362671, - "y": 1695.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": -758.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": -550.344666, - "y": 1585.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": 10, - "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" + "type": "uniform" } ], "parameters": { 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_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