{
	"name": "iterate_variations",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"combine": 1.0,
		"randomize": false,
		"step": 0.1,
		"v1": 0.0,
		"v2": 1.0,
		"variable": 0.0
	},
	"seed_int": 0,
	"shader_model": {
		"code": "",
		"global": "",
		"inputs": [
			{
				"default": "1.0",
				"function": true,
				"label": "",
				"longdesc": "The input image",
				"name": "in",
				"shortdesc": "Input",
				"type": "f"
			}
		],
		"instance": [
			"float iterate_variations_$(name)(vec2 uv, float v1, float v2, float step) {",
			"\tfloat v = 0.0;",
			"\tif (sign(step) == sign(v2-v1)) {",
			"\t\tfloat count = 1.0+floor((v2-v1)/step);",
			"\t\tfloat seedvar = _seed_variation_;",
			"\t\tvec4 var = _controlled_variation_;",
			"\t\tvar.$variable = v1;",
			"\t\tfloat input_v = $in.variation(uv, _seed_variation_, var);",
			"\t\tv = $combine;",
			"\t\tfor (float x = v1+step; x < v2; x += step) {",
			"\t\t\tvar.$variable = x;",
			"\t\t\tinput_v = $in.variation(uv, seedvar, var);",
			"\t\t\tv = $combine;",
			"\t\t\tif ($randomize) {",
			"\t\t\t\tseedvar = rand(vec2(seedvar,x));",
			"\t\t\t}",
			"\t\t}",
			"\t}",
			"\treturn v;",
			"}"
		],
		"longdesc": "Combines controlled variations for its input by iterating on the variable",
		"name": "Iterate Variations",
		"outputs": [
			{
				"f": "iterate_variations_$(name)($uv, $v1, $v2, $step)",
				"longdesc": "The output image",
				"shortdesc": "Output",
				"type": "f"
			}
		],
		"parameters": [
			{
				"default": 0.0,
				"label": "Variable",
				"longdesc": "Variable name",
				"name": "variable",
				"shortdesc": "Variable",
				"type": "enum",
				"values": [
					{
						"name": "$?1",
						"value": "x"
					},
					{
						"name": "$?2",
						"value": "y"
					},
					{
						"name": "$?3",
						"value": "z"
					},
					{
						"name": "$?4",
						"value": "w"
					}
				]
			},
			{
				"control": "None",
				"default": 0.0,
				"label": "From",
				"longdesc": "Initial value of the variable",
				"max": 1.0,
				"min": 0.0,
				"name": "v1",
				"shortdesc": "From",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1.0,
				"label": "To",
				"longdesc": "Maximum value of the variable",
				"max": 1.0,
				"min": 0.0,
				"name": "v2",
				"shortdesc": "To",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.1,
				"label": "Step",
				"longdesc": "Step value when iterating",
				"max": 1.0,
				"min": 0.0,
				"name": "step",
				"shortdesc": "Step",
				"step": 0.001,
				"type": "float"
			},
			{
				"default": 0.0,
				"label": "Combine",
				"longdesc": "Operator used to combine iterations (Add, Min, Max or average)",
				"name": "combine",
				"shortdesc": "Combine",
				"type": "enum",
				"values": [
					{
						"name": "Add",
						"value": "v+input_v"
					},
					{
						"name": "Max",
						"value": "max(v, input_v)"
					},
					{
						"name": "Min",
						"value": "min(v, input_v)"
					},
					{
						"name": "Average",
						"value": "v+input_v/count"
					}
				]
			},
			{
				"default": true,
				"label": "Randomize",
				"longdesc": "Pick different seeds for different variations",
				"name": "randomize",
				"shortdesc": "Randomize",
				"type": "boolean"
			}
		],
		"shortdesc": "Iterate Variations"
	},
	"type": "shader"
}