{ "name": "sdline", "node_position": { "x": 0, "y": 0 }, "parameters": { "ax": -0.3, "ay": -0.3, "bx": 0.3, "by": 0.3, "r": 0 }, "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": "", "longdesc": "A line or a capsule shape described as a signed distance function", "name": "sdLine", "outputs": [ { "longdesc": "The shape as signed distance function", "sdf2d": "sdLine($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5))-$r", "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" } ], "shortdesc": "sdLine" }, "type": "shader" }