mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-27 23:17:14 +01:00
127 lines
2.8 KiB
Plaintext
127 lines
2.8 KiB
Plaintext
{
|
|
"name": "tiler",
|
|
"node_position": {
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
"parameters": {
|
|
"offset": 0,
|
|
"overlap": 2,
|
|
"rotate": 0,
|
|
"scale": 0,
|
|
"select_inputs": 0,
|
|
"tx": 4,
|
|
"ty": 4
|
|
},
|
|
"shader_model": {
|
|
"code": "",
|
|
"global": "",
|
|
"inputs": [
|
|
{
|
|
"default": "0.0",
|
|
"function": true,
|
|
"label": "",
|
|
"name": "in",
|
|
"type": "f"
|
|
},
|
|
{
|
|
"default": "1.0",
|
|
"function": true,
|
|
"label": "",
|
|
"name": "mask",
|
|
"type": "f"
|
|
}
|
|
],
|
|
"instance": "float tiler_$(name)(vec2 uv, vec2 tile, int overlap, vec2 _seed) {\n\tfloat c = 0.0;\n\tfor (int dx = -overlap; dx <= overlap; ++dx) {\n\t\tfor (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\tvec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\tvec2 seed = rand2(pos+_seed);\n\t\t\tpos = fract(pos+$offset*seed/tile);\n\t\t\tfloat mask = $mask(pos+vec2(0.5));\n\t\t\tif (mask > 0.01) {\n\t\t\t\tvec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\tseed = rand2(seed);\n\t\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate;\n\t\t\t\tfloat ca = cos(angle);\n\t\t\t\tfloat sa = sin(angle);\n\t\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\t\tpv += vec2(0.5);\n\t\t\t\t$select_inputs\n\t\t\t\tc = max(c, $in(pv)*mask);\n\t\t\t}\n\t\t}\n\t}\n\treturn c;\n}",
|
|
"name": "Tiler",
|
|
"outputs": [
|
|
{
|
|
"f": "tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2($seed))",
|
|
"type": "f"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"control": "None",
|
|
"default": 4,
|
|
"label": "Tile X",
|
|
"max": 64,
|
|
"min": 1,
|
|
"name": "tx",
|
|
"step": 1,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 4,
|
|
"label": "Tile Y",
|
|
"max": 64,
|
|
"min": 1,
|
|
"name": "ty",
|
|
"step": 1,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 1,
|
|
"label": "Overlap",
|
|
"max": 5,
|
|
"min": 0,
|
|
"name": "overlap",
|
|
"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.5,
|
|
"label": "Offset",
|
|
"max": 1,
|
|
"min": 0,
|
|
"name": "offset",
|
|
"step": 0.01,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"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"
|
|
} |