{ "name": "sdsmoothboolean", "node_position": { "x": 0, "y": 0 }, "parameters": { "k": 0.15, "op": 0 }, "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": "", "longdesc": "The first shape, defined as a signed distance function", "name": "in1", "shortdesc": "Input1", "type": "sdf2d" }, { "default": "0.0", "label": "", "longdesc": "The second shape, defined as a signed distance function", "name": "in2", "shortdesc": "Input2", "type": "sdf2d" } ], "instance": "", "longdesc": "A node that performs a smooth boolean operation (union, intersection or difference) between two shapes", "name": "sdSmoothBoolean", "outputs": [ { "longdesc": "The shape generated by the boolean operation", "sdf2d": "sdSmooth$op($in1($uv), $in2($uv), $k)", "shortdesc": "Output", "type": "sdf2d" } ], "parameters": [ { "default": 0, "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": "sdSmoothBoolean" }, "type": "shader" }