mirror of
https://github.com/Relintai/mat_maker_gd.git
synced 2025-04-30 10:57:56 +02:00
127 lines
3.9 KiB
Plaintext
127 lines
3.9 KiB
Plaintext
{
|
|
"name": "voronoi",
|
|
"node_position": {
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
"parameters": {
|
|
"intensity": 1,
|
|
"randomness": 0.66,
|
|
"scale_x": 4,
|
|
"scale_y": 4,
|
|
"stretch_x": 1,
|
|
"stretch_y": 1
|
|
},
|
|
"shader_model": {
|
|
"code": "vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);",
|
|
"global": "vec4 voronoi(vec2 uv, vec2 size, vec2 stretch, float intensity, float randomness, int seed) {\n\tvec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));\n uv *= size;\n float best_distance0 = 1.0;\n float best_distance1 = 1.0;\n vec2 point0;\n vec2 point1;\n vec2 p0 = floor(uv);\n for (int dx = -1; dx < 2; ++dx) {\n \tfor (int dy = -1; dy < 2; ++dy) {\n vec2 d = vec2(float(dx), float(dy));\n vec2 p = p0+d;\n p += randomness*rand2(seed2+mod(p, size));\n float distance = length(stretch*(uv - p) / size);\n if (best_distance0 > distance) {\n \tbest_distance1 = best_distance0;\n \tbest_distance0 = distance;\n point1 = point0;\n point0 = p;\n } else if (best_distance1 > distance) {\n \tbest_distance1 = distance;\n point1 = p;\n }\n }\n }\n float edge_distance = dot(uv - 0.5*(point0+point1), normalize(point0-point1));\n \n return vec4(point0, best_distance0*length(size)*intensity, edge_distance);\n}\n",
|
|
"inputs": [
|
|
|
|
],
|
|
"instance": "",
|
|
"longdesc": "Generates several images from a tileable voronoi noise",
|
|
"name": "Voronoi",
|
|
"outputs": [
|
|
{
|
|
"f": "$(name_uv)_xyzw.z",
|
|
"longdesc": "A greyscale pattern based on the distance to cell centers",
|
|
"shortdesc": "Nodes",
|
|
"type": "f"
|
|
},
|
|
{
|
|
"f": "$(name_uv)_xyzw.w",
|
|
"longdesc": "A greyscale pattern based on the distance to borders",
|
|
"shortdesc": "Borders",
|
|
"type": "f"
|
|
},
|
|
{
|
|
"longdesc": "A color pattern that assigns a random color to each cell",
|
|
"rgb": "rand3(fract($(name_uv)_xyzw.xy))",
|
|
"shortdesc": "Random color",
|
|
"type": "rgb"
|
|
},
|
|
{
|
|
"longdesc": "An output that should be plugged into a Fill companion node",
|
|
"rgba": "vec4(fract(($(name_uv)_xyzw.xy-0.5)/vec2($scale_x, $scale_y)), vec2(1.0)/vec2($scale_x, $scale_y))",
|
|
"shortdesc": "Fill",
|
|
"type": "rgba"
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"control": "None",
|
|
"default": 4,
|
|
"label": "Scale X",
|
|
"longdesc": "The scale along the X axis",
|
|
"max": 32,
|
|
"min": 1,
|
|
"name": "scale_x",
|
|
"shortdesc": "Scale.x",
|
|
"step": 1,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 4,
|
|
"label": "Scale Y",
|
|
"longdesc": "The scale along the Y axis",
|
|
"max": 32,
|
|
"min": 1,
|
|
"name": "scale_y",
|
|
"shortdesc": "Scale.y",
|
|
"step": 1,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 1,
|
|
"label": "Stretch X",
|
|
"longdesc": "The stretch factor along the X axis",
|
|
"max": 1,
|
|
"min": 0.01,
|
|
"name": "stretch_x",
|
|
"shortdesc": "Stretch.x",
|
|
"step": 0.01,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 1,
|
|
"label": "Stretch Y",
|
|
"longdesc": "The stretch factor along the Y axis",
|
|
"max": 1,
|
|
"min": 0.01,
|
|
"name": "stretch_y",
|
|
"shortdesc": "Stretch.y",
|
|
"step": 0.01,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 0.75,
|
|
"label": "Intensity",
|
|
"longdesc": "A value factor for greyscale outputs",
|
|
"max": 1,
|
|
"min": 0,
|
|
"name": "intensity",
|
|
"shortdesc": "Intensity",
|
|
"step": 0.01,
|
|
"type": "float"
|
|
},
|
|
{
|
|
"control": "None",
|
|
"default": 1,
|
|
"label": "Randomness",
|
|
"longdesc": "The randomness of cell centers positions",
|
|
"max": 1,
|
|
"min": 0,
|
|
"name": "randomness",
|
|
"shortdesc": "Randomness",
|
|
"step": 0.01,
|
|
"type": "float"
|
|
}
|
|
],
|
|
"shortdesc": "Voronoi Noise"
|
|
},
|
|
"type": "shader"
|
|
} |