{
	"name": "voronoi2",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"intensity": 1,
		"randomness": 0.85,
		"scale_x": 4,
		"scale_y": 4,
		"stretch_x": 1,
		"stretch_y": 1
	},
	"seed_int": 0,
	"shader_model": {
		"code": "vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);",
		"global": [
			"// Based on https://www.shadertoy.com/view/ldl3W8",
			"// The MIT License",
			"// Copyright © 2013 Inigo Quilez",
			"vec3 iq_voronoi(vec2 x, vec2 size, vec2 stretch, float randomness, vec2 seed) {",
			"\tvec2 n = floor(x);",
			"\tvec2 f = fract(x);",
			"",
			"\tvec2 mg, mr, mc;",
			"\tfloat md = 8.0;",
			"\tfor (int j=-1; j<=1; j++)",
			"\tfor (int i=-1; i<=1; i++) {",
			"\t\tvec2 g = vec2(float(i),float(j));",
			"\t\tvec2 o = randomness*rand2(seed + mod(n + g + size, size));",
			"\t\tvec2 c = g + o;",
			"\t\tvec2 r = c - f;",
			"\t\tvec2 rr = r*stretch;",
			"\t\tfloat d = dot(rr,rr);",
			"",
			"\t\tif (d<md) {",
			"\t\t\tmc = c;",
			"\t\t\tmd = d;",
			"\t\t\tmr = r;",
			"\t\t\tmg = g;",
			"\t\t}",
			"\t}",
			"",
			"\tmd = 8.0;",
			"\tfor (int j=-2; j<=2; j++)",
			"\tfor (int i=-2; i<=2; i++) {",
			"\t\tvec2 g = mg + vec2(float(i),float(j));",
			"\t\tvec2 o = randomness*rand2(seed + mod(n + g + size, size));",
			"\t\tvec2 r = g + o - f;",
			"\t\tvec2 rr = (mr-r)*stretch;",
			"\t\tif (dot(rr,rr)>0.00001)",
			"\t   \t\tmd = min(md, dot(0.5*(mr+r)*stretch, normalize((r-mr)*stretch)));",
			"\t}",
			"",
			"\treturn vec3(md, mc+n);",
			"}",
			"",
			"vec4 voronoi(vec2 uv, vec2 size, vec2 stretch, float intensity, float randomness, float seed) {",
			"\tuv *= size;",
			"\tvec3 v = iq_voronoi(uv, size, stretch, randomness, rand2(vec2(seed, 1.0-seed)));",
			"\treturn vec4(v.yz, intensity*length((uv-v.yz)*stretch), v.x);",
			"}",
			""
		],
		"inputs": [

		],
		"instance": "",
		"longdesc": "Generates several images from a tileable voronoi noise",
		"name": "Voronoi",
		"outputs": [
			{
				"f": "$(name_uv)_xyzw.z",
				"longdesc": "A grayscale pattern based on the distance to cell centers",
				"shortdesc": "Nodes",
				"type": "f"
			},
			{
				"f": "$(name_uv)_xyzw.w",
				"longdesc": "A grayscale pattern based on the distance to borders",
				"shortdesc": "Borders",
				"type": "f"
			},
			{
				"fill": "round(vec4(fract(($(name_uv)_xyzw.xy-1.0)/vec2($scale_x, $scale_y)), vec2(2.0)/vec2($scale_x, $scale_y))*4096.0)/4096.0",
				"longdesc": "An output that should be plugged into a Fill companion node",
				"shortdesc": "Fill",
				"type": "fill"
			}
		],
		"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 grayscale 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"
}