material-maker/addons/material_maker/nodes/sdf3d_smoothboolean.mmg

76 lines
1.7 KiB
Plaintext

{
"name": "sdf3d_smoothboolean",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"bevel": 0,
"cx": 0,
"cy": 0,
"h": 0.08,
"k": 0.1,
"op": 2,
"r": 0.3,
"w": 0.28
},
"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(0.0)",
"label": "",
"name": "in1",
"type": "sdf3dc"
},
{
"default": "vec2(0.0)",
"label": "",
"name": "in2",
"type": "sdf3dc"
}
],
"instance": "",
"name": "SmoothBoolean",
"outputs": [
{
"sdf3dc": "sdf3d_smooth_$op($in1($uv), $in2($uv), $k)",
"type": "sdf3dc"
}
],
"parameters": [
{
"default": 2,
"label": "",
"name": "op",
"type": "enum",
"values": [
{
"name": "Union",
"value": "union"
},
{
"name": "Subtraction",
"value": "subtraction"
},
{
"name": "Intersection",
"value": "intersection"
}
]
},
{
"control": "None",
"default": 0,
"label": "",
"max": 1,
"min": 0,
"name": "k",
"step": 0.01,
"type": "float"
}
]
},
"type": "shader"
}