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

55 lines
1.2 KiB
Plaintext

{
"name": "truchet",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"shape": 1,
"size": 4
},
"shader_model": {
"code": "",
"global": "float truchet1(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv)-vec2(0.5);\n return 1.0-abs(abs((2.0*step(rand(i+seed), 0.5)-1.0)*f.x+f.y)-0.5);\n}\n\nfloat truchet2(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n float random = step(rand(i+seed), 0.5);\n f.x *= 2.0*random-1.0;\n f.x += 1.0-random;\n return 1.0-min(abs(length(f)-0.5), abs(length(1.0-f)-0.5));\n}\n",
"inputs": [
],
"instance": "",
"name": "Truchet",
"outputs": [
{
"f": "truchet$shape($uv*$size, vec2(float($seed)))",
"type": "f"
}
],
"parameters": [
{
"default": 0,
"label": "Shape",
"name": "shape",
"type": "enum",
"values": [
{
"name": "Line",
"value": "1"
},
{
"name": "Circle",
"value": "2"
}
]
},
{
"control": "None",
"default": 4,
"label": "Size",
"max": 64,
"min": 2,
"name": "size",
"step": 1,
"type": "float"
}
]
},
"type": "shader"
}