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

83 lines
2.0 KiB
Plaintext

{
"name": "sdarc",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"a1": 30,
"a2": 150,
"r1": 0.3,
"r2": 0.1
},
"shader_model": {
"code": "",
"global": "float sdArc(vec2 p, float a1, float a2, float ra, float rb) {\n\tfloat amid = 0.5*(a1+a2)+1.6+3.14*step(a1, a2);\n\tfloat alength = 0.5*(a1-a2)-1.6+3.14*step(a1, a2);\n\tvec2 sca = vec2(cos(amid), sin(amid));\n\tvec2 scb = vec2(cos(alength), sin(alength));\n p *= mat2(vec2(sca.x,sca.y),vec2(-sca.y,sca.x));\n p.x = abs(p.x);\n float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p.xy);\n return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;\n}\n",
"inputs": [
],
"instance": "",
"longdesc": "An arc as a signed distance function",
"name": "sdArc",
"outputs": [
{
"longdesc": "The arc as a signed distance function",
"sdf2d": "sdArc($uv-vec2(0.5), mod($a1, 360.0)*0.01745329251, mod($a2, 360.0)*0.01745329251, $r1, $r2)",
"shortdesc": "Output",
"type": "sdf2d"
}
],
"parameters": [
{
"control": "Angle1.a",
"default": 0,
"label": "Angle 1",
"longdesc": "The first angle of the arc",
"max": 180,
"min": -180,
"name": "a1",
"shortdesc": "Angle1",
"step": 1,
"type": "float"
},
{
"control": "Angle2.a",
"default": 0,
"label": "Angle 2",
"longdesc": "The second angle of the arc",
"max": 180,
"min": -180,
"name": "a2",
"shortdesc": "Angle2",
"step": 1,
"type": "float"
},
{
"control": "Radius1.r",
"default": 0.5,
"label": "Radius",
"longdesc": "The radius of the arc",
"max": 1,
"min": 0,
"name": "r1",
"shortdesc": "Radius",
"step": 0.01,
"type": "float"
},
{
"control": "Radius11.r",
"default": 0.1,
"label": "Width",
"longdesc": "The width of the shape around the arc",
"max": 1,
"min": 0,
"name": "r2",
"shortdesc": "Width",
"step": 0.01,
"type": "float"
}
],
"shortdesc": "sdArc"
},
"type": "shader"
}