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

82 lines
2.2 KiB
Plaintext
Raw Normal View History

{
"name": "sdf3d_smoothboolean",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
2020-10-09 22:36:25 +02:00
"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": [
{
2020-10-09 22:36:25 +02:00
"default": "vec2(100.0, 0.0)",
"label": "",
2020-10-09 22:36:25 +02:00
"longdesc": "The first shape, defined as a signed distance function",
"name": "in1",
2020-10-09 22:36:25 +02:00
"shortdesc": "Input1",
"type": "sdf3dc"
},
{
2020-10-09 22:36:25 +02:00
"default": "vec2(100.0, 0.0)",
"label": "",
2020-10-09 22:36:25 +02:00
"longdesc": "The second shape, defined as a signed distance function",
"name": "in2",
2020-10-09 22:36:25 +02:00
"shortdesc": "Input2",
"type": "sdf3dc"
}
],
"instance": "",
"longdesc": "Performs a smooth boolean operation (union, intersection or difference) between two shapes",
"name": "SmoothBoolean",
"outputs": [
{
2020-10-09 22:36:25 +02:00
"longdesc": "The shape generated by the boolean operation",
"sdf3dc": "sdf3d_smooth_$op($in1($uv), $in2($uv), $k)",
2020-10-09 22:36:25 +02:00
"shortdesc": "Output",
"type": "sdf3dc"
}
],
"parameters": [
{
"default": 2,
"label": "",
2020-10-09 22:36:25 +02:00
"longdesc": "The operation performed by this node",
"name": "op",
2020-10-09 22:36:25 +02:00
"shortdesc": "Operation",
"type": "enum",
"values": [
{
"name": "Union",
"value": "union"
},
{
"name": "Subtraction",
"value": "subtraction"
},
{
"name": "Intersection",
"value": "intersection"
}
]
},
{
"control": "None",
"default": 0,
"label": "",
2020-10-09 22:36:25 +02:00
"longdesc": "The smoothness of the boolean operation",
"max": 1,
"min": 0,
"name": "k",
2020-10-09 22:36:25 +02:00
"shortdesc": "Smoothness",
"step": 0.01,
"type": "float"
}
2020-10-09 22:36:25 +02:00
],
"shortdesc": "SmoothBoolean"
},
"type": "shader"
}