{
	"name": "fill_to_uv2",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"mode": 0
	},
	"seed_int": 0,
	"shader_model": {
		"code": "vec4 $(name_uv)_bb = $in($uv);",
		"global": [
			"vec3 fill_to_uv_stretch(vec2 coord, vec4 bb, float seed) {",
			"\tvec2 uv_islands = fract(coord-bb.xy)/bb.zw;",
			"\tfloat random_value = rand(vec2(seed)+bb.xy+bb.zw);",
			"\treturn vec3(uv_islands, random_value);",
			"}",
			"",
			"vec3 fill_to_uv_square(vec2 coord, vec4 bb, float seed) {",
			"\tvec2 uv_islands;",
			"\tif (bb.z > bb.w) {",
			"\t\tvec2 adjusted_coord = coord + vec2(0.0, (bb.z - bb.w) / 2.0);",
			"\t\tuv_islands = fract(adjusted_coord-bb.xy)/bb.zz;",
			"\t} else {",
			"\t\tvec2 adjusted_coord = coord + vec2((bb.w - bb.z) / 2.0, 0.0);",
			"\t\tuv_islands = fract(adjusted_coord-bb.xy)/bb.ww;",
			"\t}",
			"\tfloat random_value = rand(vec2(seed)+bb.xy+bb.zw);",
			"\treturn vec3(uv_islands, random_value);",
			"}"
		],
		"inputs": [
			{
				"default": "vec4(0.0)",
				"label": "",
				"longdesc": "The input fill data, to be connected to the output of a Fill node",
				"name": "in",
				"shortdesc": "Input",
				"type": "fill"
			}
		],
		"instance": "",
		"longdesc": "A fill companion node that generated an UV map that follows each filled area",
		"name": "Fill to UV      ",
		"outputs": [
			{
				"longdesc": "The generated output UV map, to be connected to a Custom UV node",
				"rgb": "fill_to_uv_$mode($uv, $(name_uv)_bb, float($seed))",
				"shortdesc": "Output",
				"type": "rgb"
			}
		],
		"parameters": [
			{
				"default": 0,
				"label": "",
				"longdesc": "The mode decides how the UVs are layed out on each bounding box:\n- Stretch mode where the UV layout is stretched to the bounding box. \n- Square mode where the UV layout is even and centerered based on the longest axis of the bounding box.",
				"name": "mode",
				"shortdesc": "Mode",
				"type": "enum",
				"values": [
					{
						"name": "Stretch",
						"value": "stretch"
					},
					{
						"name": "Square",
						"value": "square"
					}
				]
			}
		],
		"shortdesc": "Fill to UV"
	},
	"type": "shader"
}