{
	"connections": [
		{
			"from": "gen_inputs",
			"from_port": 0,
			"to": "tones_map",
			"to_port": 0
		},
		{
			"from": "tones_map",
			"from_port": 0,
			"to": "gen_outputs",
			"to_port": 0
		},
		{
			"from": "combine",
			"from_port": 0,
			"to": "iterate_buffer",
			"to_port": 0
		},
		{
			"from": "iterate_buffer",
			"from_port": 0,
			"to": "decompose",
			"to_port": 0
		},
		{
			"from": "iterate_buffer",
			"from_port": 1,
			"to": "14423",
			"to_port": 0
		},
		{
			"from": "14423",
			"from_port": 0,
			"to": "iterate_buffer",
			"to_port": 1
		},
		{
			"from": "gen_inputs",
			"from_port": 0,
			"to": "combine",
			"to_port": 0
		},
		{
			"from": "gen_inputs",
			"from_port": 0,
			"to": "combine",
			"to_port": 1
		},
		{
			"from": "decompose",
			"from_port": 0,
			"to": "tones_map",
			"to_port": 1
		},
		{
			"from": "decompose",
			"from_port": 1,
			"to": "tones_map",
			"to_port": 2
		}
	],
	"label": "Auto Tones",
	"longdesc": "Finds the minimum and maximum values in the input texture and tone maps it to the full 0.0 - 1.0 range.",
	"name": "auto_tones",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"nodes": [
		{
			"name": "tones_map",
			"node_position": {
				"x": 1552.52844238281,
				"y": -98.2698974609375
			},
			"parameters": {

			},
			"seed": -54302,
			"shader_model": {
				"code": "",
				"global": "",
				"inputs": [
					{
						"default": "0.5",
						"label": "",
						"longdesc": "The input image",
						"name": "in",
						"shortdesc": "Input",
						"type": "f"
					},
					{
						"default": "0.0",
						"label": "",
						"name": "in_min",
						"type": "f"
					},
					{
						"default": "1.0",
						"label": "",
						"name": "in_max",
						"type": "f"
					}
				],
				"instance": "",
				"longdesc": "Maps linearly an input tones interval to an output tones interval.",
				"name": "Mapping",
				"outputs": [
					{
						"f": "($in($uv)-$in_min($uv))/($in_max($uv)-$in_min($uv))",
						"longdesc": "Shows the generated remapped image",
						"shortdesc": "Output",
						"type": "f"
					}
				],
				"parameters": [],
				"shortdesc": "Tones map"
			},
			"type": "shader"
		},
		{
			"name": "gen_inputs",
			"node_position": {
				"x": 439.528564453125,
				"y": -98.5357208251953
			},
			"parameters": {

			},
			"ports": [
				{
					"group_size": 0,
					"longdesc": "The input image",
					"name": "in",
					"shortdesc": "Input",
					"type": "f"
				}
			],
			"seed": -55041,
			"type": "ios"
		},
		{
			"name": "gen_outputs",
			"node_position": {
				"x": 1747.40002441406,
				"y": -97.5357208251953
			},
			"parameters": {

			},
			"ports": [
				{
					"group_size": 0,
					"longdesc": "Shows the generated remapped image",
					"name": "out",
					"shortdesc": "Output",
					"type": "f"
				}
			],
			"seed": -15114,
			"type": "ios"
		},
		{
			"name": "gen_parameters",
			"node_position": {
				"x": 979.664306640625,
				"y": -181.400756835938
			},
			"parameters": {
				"size": 11
			},
			"seed": -32042,
			"type": "remote",
			"widgets": [
				{
					"label": "",
					"linked_widgets": [
						{
							"node": "iterate_buffer",
							"widget": "size"
						},
						{
							"node": "14423",
							"widget": "size"
						}
					],
					"name": "size",
					"type": "linked_control"
				}
			]
		},
		{
			"name": "decompose",
			"node_position": {
				"x": 1355.62927246094,
				"y": -50.0531921386719
			},
			"parameters": {

			},
			"seed": 35843,
			"type": "decompose"
		},
		{
			"name": "combine",
			"node_position": {
				"x": 907.629272460938,
				"y": -50.0531921386719
			},
			"parameters": {

			},
			"seed": -46531,
			"type": "combine"
		},
		{
			"name": "iterate_buffer",
			"node_position": {
				"x": 1077.62927246094,
				"y": -50.0531921386719
			},
			"parameters": {
				"autostop": false,
				"f32": false,
				"filter": false,
				"iterations": 13,
				"mipmap": false,
				"shrink": true,
				"size": 11
			},
			"seed": 29168,
			"seed_locked": true,
			"type": "iterate_buffer"
		},
		{
			"name": "14423",
			"node_position": {
				"x": 1087.62927246094,
				"y": 164.946807861328
			},
			"parameters": {
				"size": 11
			},
			"seed": 53617,
			"shader_model": {
				"code": "",
				"global": "",
				"inputs": [
					{
						"default": "vec3(0.0)",
						"function": true,
						"label": "",
						"name": "in",
						"type": "rgb"
					}
				],
				"instance": [
					"vec3 $(name)_compare(vec2 uv, float size) {",
					"\tfloat iter = $in(uv).b;",
					"\tsize = size / pow(2.0, (iter * 100.0) );",
					"\titer += 0.01;",
					"\tfloat pixel_offset = 1.0 / size;",
					"\tvec2 half_res_uv = floor(uv * size / 2.0) / size * 2.0 + pixel_offset / 2.0;",
					"\tvec3 values[4];",
					"\tvalues[0] = $in(half_res_uv);",
					"\tvalues[1] = $in(half_res_uv + vec2(pixel_offset, 0.0));",
					"\tvalues[2] = $in(half_res_uv + vec2(0.0, pixel_offset));",
					"\tvalues[3] = $in(half_res_uv + vec2(pixel_offset, pixel_offset));",
					"\t",
					"\tfloat lowest = 1.0;",
					"\tfloat highest = 0.0;",
					"\t",
					"\tfor (int i = 0; i < 4; i++) {",
					"\t\tlowest = values[i].r < lowest ? values[i].r : lowest;",
					"\t\thighest = values[i].g > highest ? values[i].g : highest;",
					"\t}",
					"\t",
					"\treturn vec3( lowest, highest , iter);",
					"}"
				],
				"name": "Compare Neighbor",
				"outputs": [
					{
						"rgb": "$(name)_compare($uv, $size)",
						"type": "rgb"
					}
				],
				"parameters": [
					{
						"default": 10,
						"first": 1,
						"label": "",
						"last": 13,
						"name": "size",
						"type": "size"
					}
				]
			},
			"type": "shader"
		}
	],
	"parameters": {
		"size": 11
	},
	"seed_int": 0,
	"shortdesc": "Auto Tones",
	"type": "graph"
}