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

76 lines
1.3 KiB
Plaintext

{
"name": "sdline",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"ax": 0.224,
"ay": 0.2672,
"bx": -0.272,
"by": -0.2344,
"cx": 0,
"cy": 0,
"h": 0.2,
"r": 0.3,
"w": 0.3
},
"shader_model": {
"code": "",
"global": "float sdLine( in vec2 p, in vec2 a, in 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 length( pa - ba*h );\n}\n",
"inputs": [
],
"instance": "",
"name": "sdLine",
"outputs": [
{
"sdf2d": "sdLine($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5))",
"type": "sdf2d"
}
],
"parameters": [
{
"control": "P1.x",
"default": 0,
"label": "A X",
"max": 1,
"min": -1,
"name": "ax",
"step": 0.01,
"type": "float"
},
{
"control": "P1.y",
"default": 0,
"label": "A Y",
"max": 1,
"min": -1,
"name": "ay",
"step": 0.01,
"type": "float"
},
{
"control": "P2.x",
"default": 1,
"label": "B X",
"max": 1,
"min": -1,
"name": "bx",
"step": 0.01,
"type": "float"
},
{
"control": "P2.y",
"default": 1,
"label": "B Y",
"max": 1,
"min": -1,
"name": "by",
"step": 0.01,
"type": "float"
}
]
},
"type": "shader"
}