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

127 lines
3.9 KiB
Plaintext
Raw Normal View History

2019-10-27 14:36:16 +01:00
{
"name": "voronoi",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"intensity": 1,
2020-09-26 17:13:09 +02:00
"randomness": 0.66,
"scale_x": 4,
"scale_y": 4,
"stretch_x": 1,
"stretch_y": 1
2019-10-27 14:36:16 +01:00
},
"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",
2019-10-27 14:36:16 +01:00
"inputs": [
],
"instance": "",
2020-09-26 17:13:09 +02:00
"longdesc": "A node that generates several images from a tileable voronoi noise",
2019-10-27 14:36:16 +01:00
"name": "Voronoi",
"outputs": [
{
"f": "$(name_uv)_xyzw.z",
2020-09-26 17:13:09 +02:00
"longdesc": "A greyscale pattern based on the distance to cell centers",
"shortdesc": "Nodes",
2019-10-27 14:36:16 +01:00
"type": "f"
},
{
"f": "$(name_uv)_xyzw.w",
2020-09-26 17:13:09 +02:00
"longdesc": "A greyscale pattern based on the distance to borders",
"shortdesc": "Borders",
2019-10-27 14:36:16 +01:00
"type": "f"
},
{
2020-09-26 17:13:09 +02:00
"longdesc": "A color pattern that assigns a random color to each cell",
"rgb": "rand3(fract($(name_uv)_xyzw.xy))",
2020-09-26 17:13:09 +02:00
"shortdesc": "Random color",
2019-10-27 14:36:16 +01:00
"type": "rgb"
},
{
2020-09-26 17:13:09 +02:00
"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))",
2020-09-26 17:13:09 +02:00
"shortdesc": "Fill",
"type": "rgba"
2019-10-27 14:36:16 +01:00
}
],
"parameters": [
{
"control": "None",
2019-10-27 14:36:16 +01:00
"default": 4,
"label": "Scale X",
2020-09-26 17:13:09 +02:00
"longdesc": "The scale along the X axis",
2019-10-27 14:36:16 +01:00
"max": 32,
"min": 1,
"name": "scale_x",
2020-09-26 17:13:09 +02:00
"shortdesc": "Scale.x",
2019-10-27 14:36:16 +01:00
"step": 1,
"type": "float"
},
{
"control": "None",
2019-10-27 14:36:16 +01:00
"default": 4,
"label": "Scale Y",
2020-09-26 17:13:09 +02:00
"longdesc": "The scale along the Y axis",
2019-10-27 14:36:16 +01:00
"max": 32,
"min": 1,
"name": "scale_y",
2020-09-26 17:13:09 +02:00
"shortdesc": "Scale.y",
2019-10-27 14:36:16 +01:00
"step": 1,
"type": "float"
},
{
"control": "None",
"default": 1,
"label": "Stretch X",
2020-09-26 17:13:09 +02:00
"longdesc": "The stretch factor along the X axis",
"max": 1,
"min": 0.01,
"name": "stretch_x",
2020-09-26 17:13:09 +02:00
"shortdesc": "Stretch.x",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 1,
"label": "Stretch Y",
2020-09-26 17:13:09 +02:00
"longdesc": "The stretch factor along the Y axis",
"max": 1,
"min": 0.01,
"name": "stretch_y",
2020-09-26 17:13:09 +02:00
"shortdesc": "Stretch.y",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 0.75,
2019-10-27 14:36:16 +01:00
"label": "Intensity",
2020-09-26 17:13:09 +02:00
"longdesc": "A value factor for greyscale outputs",
2019-10-27 14:36:16 +01:00
"max": 1,
"min": 0,
"name": "intensity",
2020-09-26 17:13:09 +02:00
"shortdesc": "Intensity",
"step": 0.01,
2019-10-27 14:36:16 +01:00
"type": "float"
},
{
"control": "None",
2019-10-27 14:36:16 +01:00
"default": 1,
"label": "Randomness",
2020-09-26 17:13:09 +02:00
"longdesc": "The randomness of cell centers positions",
2019-10-27 14:36:16 +01:00
"max": 1,
"min": 0,
"name": "randomness",
2020-09-26 17:13:09 +02:00
"shortdesc": "Randomness",
2019-10-27 14:36:16 +01:00
"step": 0.01,
"type": "float"
}
2020-09-26 17:13:09 +02:00
],
"shortdesc": "Voronoi Noise"
2019-10-27 14:36:16 +01:00
},
"type": "shader"
}