material-maker/addons/material_maker/nodes/truchet.mmg
2019-10-27 14:36:16 +01:00

57 lines
1.2 KiB
Plaintext

{
"name": "truchet",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"Size": 4,
"shape": 1,
"size": 4,
"type": 1
},
"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($seed, $seed))",
"type": "f"
}
],
"parameters": [
{
"default": 0,
"label": "Shape",
"name": "shape",
"type": "enum",
"values": [
{
"name": "Line",
"value": "1"
},
{
"name": "Circle",
"value": "2"
}
]
},
{
"default": 4,
"label": "Size",
"max": 64,
"min": 2,
"name": "size",
"step": 1,
"type": "float",
"widget": "spinbox"
}
]
},
"type": "shader"
}