mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
89 lines
2.7 KiB
Plaintext
89 lines
2.7 KiB
Plaintext
{
|
|
"name": "shape",
|
|
"node_position": {
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
"parameters": {
|
|
"edge": 0.5,
|
|
"radius": 0.9,
|
|
"shape": 1,
|
|
"sides": 6
|
|
},
|
|
"shader_model": {
|
|
"code": "",
|
|
"global": "float shape_circle(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float distance = length(uv);\n return clamp((1.0-distance/size)/edge, 0.0, 1.0);\n}\n\nfloat shape_polygon(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = atan(uv.x, uv.y)+3.14159265359;\n float slice = 6.28318530718/sides;\n return clamp((size-cos(floor(0.5+angle/slice)*slice-angle)*length(uv))/(edge*size), 0.0, 1.0);\n}\n\nfloat shape_star(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = atan(uv.x, uv.y);\n float slice = 6.28318530718/sides;\n return clamp((size-cos(floor(1.5+angle/slice-2.0*step(0.5*slice, mod(angle, slice)))*slice-angle)*length(uv))/(edge*size), 0.0, 1.0);\n}\n\nfloat shape_curved_star(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = 2.0*(atan(uv.x, uv.y)+3.14159265359);\n float slice = 6.28318530718/sides;\n return clamp((size-cos(floor(0.5+0.5*angle/slice)*2.0*slice-angle)*length(uv))/(edge*size), 0.0, 1.0);\n}\n\nfloat shape_rays(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = 0.5*max(edge, 1.0e-8)*size;\n\tfloat slice = 6.28318530718/sides;\n float angle = mod(atan(uv.x, uv.y)+3.14159265359, slice)/slice;\n return clamp(min((size-angle)/edge, angle/edge), 0.0, 1.0);\n}\n\n",
|
|
"inputs": [
|
|
|
|
],
|
|
"instance": "",
|
|
"name": "Shape",
|
|
"outputs": [
|
|
{
|
|
"f": "shape_$(shape)($(uv), $(sides), $(radius), $(edge))",
|
|
"type": "f"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"default": 0,
|
|
"label": "",
|
|
"name": "shape",
|
|
"type": "enum",
|
|
"values": [
|
|
{
|
|
"name": "Circle",
|
|
"value": "circle"
|
|
},
|
|
{
|
|
"name": "Polygon",
|
|
"value": "polygon"
|
|
},
|
|
{
|
|
"name": "Star",
|
|
"value": "star"
|
|
},
|
|
{
|
|
"name": "Curved star",
|
|
"value": "curved_star"
|
|
},
|
|
{
|
|
"name": "Rays",
|
|
"value": "rays"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 3,
|
|
"label": "",
|
|
"max": 32,
|
|
"min": 2,
|
|
"name": "sides",
|
|
"step": 1,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 1,
|
|
"label": "",
|
|
"max": 1,
|
|
"min": 0,
|
|
"name": "radius",
|
|
"step": 0.01,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 0.2,
|
|
"label": "",
|
|
"max": 1,
|
|
"min": 0,
|
|
"name": "edge",
|
|
"step": 0.01,
|
|
"type": "float"
|
|
}
|
|
]
|
|
},
|
|
"type": "shader"
|
|
} |