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

135 lines
2.6 KiB
Plaintext

{
"name": "sdline",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"ax": -0.3,
"ay": -0.3,
"bx": 0.3,
"by": 0.3,
"profile": {
"points": [
{
"ls": 0,
"rs": 0,
"x": 0,
"y": 1
},
{
"ls": 0,
"rs": 0,
"x": 1,
"y": 1
}
],
"type": "Curve"
},
"r": 0.1
},
"shader_model": {
"code": "vec2 $(name_uv)_sdl = sdLine($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5));",
"global": "vec2 sdLine(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p-a, ba = b-a;\n float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0);\n return vec2(length(pa-ba*h), h);\n}\n",
"inputs": [
],
"instance": "",
"longdesc": "A line or a capsule shape described as a signed distance function",
"name": "sdLine",
"outputs": [
{
"longdesc": "The shape as signed distance function",
"sdf2d": "$(name_uv)_sdl.x-$r*$profile($(name_uv)_sdl.y)",
"shortdesc": "Output",
"type": "sdf2d"
}
],
"parameters": [
{
"control": "P1.x",
"default": 0,
"label": "A X",
"longdesc": "The position on the X axis of the first point of the line",
"max": 1,
"min": -1,
"name": "ax",
"shortdesc": "A.x",
"step": 0.01,
"type": "float"
},
{
"control": "P1.y",
"default": 0,
"label": "A Y",
"longdesc": "The position on the Y axis of the first point of the line",
"max": 1,
"min": -1,
"name": "ay",
"shortdesc": "A.y",
"step": 0.01,
"type": "float"
},
{
"control": "P2.x",
"default": 1,
"label": "B X",
"longdesc": "The position on the X axis of the second point of the line",
"max": 1,
"min": -1,
"name": "bx",
"shortdesc": "B.x",
"step": 0.01,
"type": "float"
},
{
"control": "P2.y",
"default": 1,
"label": "B Y",
"longdesc": "The position on the Y axis of the second point of the line",
"max": 1,
"min": -1,
"name": "by",
"shortdesc": "B.y",
"step": 0.01,
"type": "float"
},
{
"control": "Radius1.r",
"default": 0,
"label": "Width",
"longdesc": "The width of the capsule shape around the line",
"max": 1,
"min": 0,
"name": "r",
"shortdesc": "Width",
"step": 0.01,
"type": "float"
},
{
"default": {
"points": [
{
"ls": 0,
"rs": 0,
"x": 0,
"y": 1
},
{
"ls": 0,
"rs": 0,
"x": 1,
"y": 1
}
],
"type": "Curve"
},
"label": "Profile",
"name": "profile",
"type": "curve"
}
],
"shortdesc": "sdLine"
},
"type": "shader"
}