{
	"name": "circle_splatter_color",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"count": 20,
		"i_rotate": 0,
		"i_scale": 0,
		"opacity": 0,
		"radius": 0.4,
		"rings": 2,
		"rotate": 0,
		"scale": 0,
		"scale_x": 1,
		"scale_y": 1,
		"select_inputs": 0,
		"spiral": 0,
		"variations": false
	},
	"seed_int": 0,
	"shader_model": {
		"code": "",
		"global": "",
		"inputs": [
			{
				"default": "vec4(0.0, 0.0, 0.0, 1.0)",
				"function": true,
				"label": "",
				"longdesc": "The input image or atlas of 4 or 16 input images",
				"name": "in",
				"shortdesc": "Input",
				"type": "rgba"
			},
			{
				"default": "1.0",
				"function": true,
				"label": "",
				"longdesc": "The mask applied to the pattern",
				"name": "mask",
				"shortdesc": "Mask",
				"type": "f"
			}
		],
		"instance": [
			"vec4 splatter_$(name)(vec2 uv, int count, int rings, vec2 seed) {",
			"\tvec4 c = vec4(0.0);",
			"\tvec3 rc = vec3(0.0);",
			"\tvec3 rc1;",
			"\tseed = rand2(seed);",
			"\tfor (int i = 0; i < count; ++i) {",
			"\t\tfloat a = -1.57079632679+6.28318530718*float(i)*$rings/float(count);",
			"\t\tfloat rings_distance = ceil(float(i+1)*float(rings)/float(count))/float(rings);",
			"\t\tfloat spiral_distance = float(i+1)/float(count);",
			"\t\tvec2 pos = $radius*mix(rings_distance, spiral_distance, $spiral)*vec2(cos(a), sin(a));",
			"\t\tfloat mask = $mask(fract(pos-vec2(0.5)));",
			"\t\tif (mask > 0.01) {",
			"\t\t\tvec2 pv = uv-0.5-pos;",
			"\t\t\trc1 = rand3(seed);",
			"\t\t\tseed = rand2(seed);",
			"\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251 + (a+1.57079632679) * $i_rotate;",
			"\t\t\tfloat ca = cos(angle);",
			"\t\t\tfloat sa = sin(angle);",
			"\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);",
			"\t\t\tpv /= mix(1.0, float(i+1)/float(count+1), $i_scale);",
			"\t\t\tpv /= vec2($scale_x, $scale_y);",
			"\t\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;",
			"\t\t\tpv += vec2(0.5);",
			"\t\t\tseed = rand2(seed);",
			"\t\t\tif (pv != clamp(pv, vec2(0.0), vec2(1.0))) {",
			"\t\t\t\tcontinue;",
			"\t\t\t}",
			"\t\t\t$select_inputs",
			"\t\t\tvec4 n = $in.variation(pv, $variations ? seed.x : 0.0);",
			"\t\t\tfloat na = n.a*mask*(1.0-$opacity*seed.x);\t\t\t",
			"\t\t\tc = mix(c, n, na);",
			"\t\t}",
			"\t}",
			"\treturn c;",
			"}",
			""
		],
		"longdesc": "Spreads several occurences of an input image in a circle or spiral pattern.",
		"name": "Color Circle Splatter",
		"outputs": [
			{
				"longdesc": "Shows the generated pattern",
				"rgba": "splatter_$(name)($uv, int($count), int($rings), vec2(float($seed)))",
				"shortdesc": "Output",
				"type": "rgba"
			}
		],
		"parameters": [
			{
				"control": "None",
				"default": 10,
				"label": "Count",
				"longdesc": "The number of occurences of the input image",
				"max": 256,
				"min": 1,
				"name": "count",
				"shortdesc": "Count",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Rings",
				"longdesc": "The number of rings of the circle pattern",
				"max": 16,
				"min": 1,
				"name": "rings",
				"shortdesc": "Rings",
				"step": 1,
				"type": "float"
			},
			{
				"default": 0,
				"label": "Inputs",
				"longdesc": "The input type of the node:\n- 1: single image\n- 4: atlas of 4 images\n- 16: atlas of 16 images\nAtlases can be created using the Tile2x2 node.",
				"name": "select_inputs",
				"shortdesc": "Input",
				"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": 1,
				"label": "Scale X",
				"longdesc": "The scale of input images on the X axis",
				"max": 2,
				"min": 0,
				"name": "scale_x",
				"shortdesc": "Scale.x",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Scale Y",
				"longdesc": "The scale of input images on the Y axis",
				"max": 2,
				"min": 0,
				"name": "scale_y",
				"shortdesc": "Scale.y",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.25,
				"label": "Radius",
				"longdesc": "The radius of the outer circle pattern",
				"max": 0.5,
				"min": 0,
				"name": "radius",
				"shortdesc": "Radius",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Spiral",
				"longdesc": "The type of pattern:\n- 0: circles\n- 1: spiral",
				"max": 1,
				"min": 0,
				"name": "spiral",
				"shortdesc": "Spiral",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Inc Rotate",
				"longdesc": "The rotate increment along the pattern",
				"max": 1,
				"min": 0,
				"name": "i_rotate",
				"shortdesc": "IncRotate",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Inc Scale",
				"longdesc": "The scale increment of the pattern",
				"max": 1,
				"min": 0,
				"name": "i_scale",
				"shortdesc": "IncScale",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Rnd Rotate",
				"longdesc": "The random rotation applied to each image instance",
				"max": 180,
				"min": 0,
				"name": "rotate",
				"shortdesc": "RndRotate",
				"step": 0.1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Rnd Scale",
				"longdesc": "The random scale applied to each image instance",
				"max": 1,
				"min": 0,
				"name": "scale",
				"shortdesc": "RndScale",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.5,
				"label": "Rnd Opacity",
				"longdesc": "The random opacity applied to each image instance",
				"max": 1,
				"min": 0,
				"name": "opacity",
				"shortdesc": "RndOpacity",
				"step": 0.01,
				"type": "float"
			},
			{
				"default": false,
				"label": "Variations",
				"name": "variations",
				"type": "boolean"
			}
		]
	},
	"type": "shader"
}