material-maker/addons/material_maker/nodes/splatter.mmg
2020-02-15 11:16:18 +01:00

87 lines
1.9 KiB
Plaintext

{
"name": "splatter",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"count": 25,
"rotate": 0,
"scale": 0,
"select_inputs": 0
},
"shader_model": {
"code": "",
"global": "",
"inputs": [
{
"default": "0.0",
"function": true,
"label": "",
"name": "in",
"type": "f"
}
],
"instance": "float splatter_$(name)(vec2 uv, int count, vec2 seed) {\n\tfloat c = 0.0;\n\tfor (int i = 0; i < count; ++i) {\n\t\tseed = rand2(seed);\n\t\tvec2 pv = fract(uv - seed);\n\t\tseed = rand2(seed);\n\t\tpv -= vec2(0.5);\n\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate;\n\t\tfloat ca = cos(angle);\n\t\tfloat sa = sin(angle);\n\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\tpv += vec2(0.5);\n\t\t$select_inputs\n\t\tc = max(c, $in(pv));\n\t}\n\treturn c;\n}",
"name": "Splatter",
"outputs": [
{
"f": "splatter_$(name)($uv, int($count), vec2($seed))",
"type": "f"
}
],
"parameters": [
{
"control": "None",
"default": 10,
"label": "Count",
"max": 100,
"min": 1,
"name": "count",
"step": 1,
"type": "float"
},
{
"default": 0,
"label": "Inputs",
"name": "select_inputs",
"type": "enum",
"values": [
{
"name": "1",
"value": " "
},
{
"name": "4",
"value": "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
},
{
"name": "16",
"value": "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
}
]
},
{
"control": "None",
"default": 0,
"label": "Rotate",
"max": 180,
"min": 0,
"name": "rotate",
"step": 0.1,
"type": "float"
},
{
"control": "None",
"default": 0,
"label": "Scale",
"max": 1,
"min": 0,
"name": "scale",
"step": 0.01,
"type": "float"
}
]
},
"type": "shader"
}