{ "name": "sdf3d_smoothboolean", "node_position": { "x": 0, "y": 0 }, "parameters": { "k": 0.15, "op": 0 }, "shader_model": { "code": "", "global": "vec2 sdf3d_smooth_union(vec2 d1, vec2 d2, float k) {\n float h = clamp(0.5+0.5*(d2.x-d1.x)/k, 0.0, 1.0);\n return vec2(mix(d2.x, d1.x, h)-k*h*(1.0-h), mix(d2.y, d1.y, step(d1.x, d2.x)));\n}\n\nvec2 sdf3d_smooth_subtraction(vec2 d1, vec2 d2, float k ) {\n float h = clamp(0.5-0.5*(d2.x+d1.x)/k, 0.0, 1.0);\n return vec2(mix(d2.x, -d1.x, h )+k*h*(1.0-h), d2.y);\n}\n\nvec2 sdf3d_smooth_intersection(vec2 d1, vec2 d2, float k ) {\n float h = clamp(0.5-0.5*(d2.x-d1.x)/k, 0.0, 1.0);\n return vec2(mix(d2.x, d1.x, h)+k*h*(1.0-h), mix(d1.y, d2.y, step(d1.x, d2.x)));\n}\n", "inputs": [ { "default": "vec2(100.0, 0.0)", "label": "", "longdesc": "The first shape, defined as a signed distance function", "name": "in1", "shortdesc": "Input1", "type": "sdf3dc" }, { "default": "vec2(100.0, 0.0)", "label": "", "longdesc": "The second shape, defined as a signed distance function", "name": "in2", "shortdesc": "Input2", "type": "sdf3dc" } ], "instance": "", "longdesc": "Performs a smooth boolean operation (union, intersection or difference) between two shapes", "name": "SmoothBoolean", "outputs": [ { "longdesc": "The shape generated by the boolean operation", "sdf3dc": "sdf3d_smooth_$op($in1($uv), $in2($uv), $k)", "shortdesc": "Output", "type": "sdf3dc" } ], "parameters": [ { "default": 2, "label": "", "longdesc": "The operation performed by this node", "name": "op", "shortdesc": "Operation", "type": "enum", "values": [ { "name": "Union", "value": "union" }, { "name": "Subtraction", "value": "subtraction" }, { "name": "Intersection", "value": "intersection" } ] }, { "control": "None", "default": 0, "label": "", "longdesc": "The smoothness of the boolean operation", "max": 1, "min": 0, "name": "k", "shortdesc": "Smoothness", "step": 0.01, "type": "float" } ], "shortdesc": "SmoothBoolean" }, "type": "shader" }