{
	"connections": [
		{
			"from": "gen_inputs",
			"from_port": 0,
			"to": "buffer",
			"to_port": 0
		},
		{
			"from": "buffer",
			"from_port": 0,
			"to": "edge_detect_3_3_2",
			"to_port": 0
		},
		{
			"from": "gen_inputs",
			"from_port": 1,
			"to": "edge_detect_3_3_2",
			"to_port": 1
		},
		{
			"from": "edge_detect_3_3_2",
			"from_port": 0,
			"to": "buffer_2",
			"to_port": 0
		},
		{
			"from": "buffer_2",
			"from_port": 0,
			"to": "gen_outputs",
			"to_port": 0
		}
	],
	"label": "Slope Blur",
	"longdesc": "Applies a blur effect on its input, following slopes of an input height map",
	"name": "slope_blur",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"nodes": [
		{
			"name": "buffer",
			"node_position": {
				"x": -395.25,
				"y": -274.75
			},
			"parameters": {
				"lod": 0,
				"size": 10
			},
			"seed": 1477,
			"type": "buffer"
		},
		{
			"name": "gen_parameters",
			"node_position": {
				"x": -462.666626,
				"y": -397.666656
			},
			"parameters": {
				"param0": 10,
				"param1": 30
			},
			"seed": 10365,
			"type": "remote",
			"widgets": [
				{
					"label": "Grid size",
					"linked_widgets": [
						{
							"node": "buffer",
							"widget": "size"
						},
						{
							"node": "edge_detect_3_3_2",
							"widget": "size"
						},
						{
							"node": "buffer_2",
							"widget": "size"
						}
					],
					"longdesc": "The resolution of the input image",
					"name": "param0",
					"shortdesc": "Size",
					"type": "linked_control"
				},
				{
					"label": "Sigma",
					"linked_widgets": [
						{
							"node": "edge_detect_3_3_2",
							"widget": "sigma"
						}
					],
					"longdesc": "The strength of the blur filter",
					"name": "param1",
					"shortdesc": "Sigma",
					"type": "linked_control"
				}
			]
		},
		{
			"name": "gen_inputs",
			"node_position": {
				"x": -872.666626,
				"y": -243.392853
			},
			"parameters": {

			},
			"ports": [
				{
					"group_size": 0,
					"longdesc": "The input image",
					"name": "in",
					"shortdesc": "Input",
					"type": "rgba"
				},
				{
					"group_size": 0,
					"longdesc": "A height map whose slopes control the strength and direction of the blur filter",
					"name": "heightmap",
					"shortdesc": "Height map",
					"type": "f"
				}
			],
			"seed": 91624,
			"seed_locked": true,
			"type": "ios"
		},
		{
			"name": "gen_outputs",
			"node_position": {
				"x": -45.452393,
				"y": -195.392853
			},
			"parameters": {

			},
			"ports": [
				{
					"group_size": 0,
					"longdesc": "Shows the generated blurred image",
					"name": "port0",
					"shortdesc": "Output",
					"type": "rgba"
				}
			],
			"seed": 30896,
			"type": "ios"
		},
		{
			"name": "edge_detect_3_3_2",
			"node_position": {
				"x": -401.725464,
				"y": -199.178955
			},
			"parameters": {
				"sigma": 30,
				"size": 10
			},
			"seed": -47470,
			"seed_locked": true,
			"shader_model": {
				"code": "",
				"global": "",
				"inputs": [
					{
						"default": "vec4(1.0)",
						"function": true,
						"label": "",
						"name": "in",
						"type": "rgba"
					},
					{
						"default": "1.0",
						"function": true,
						"label": "",
						"name": "heightmap",
						"type": "f"
					}
				],
				"instance": [
					"vec4 $(name)_fct(vec2 uv) {",
					"\tfloat dx = 1.0/$size;",
					"\tfloat v = $heightmap(uv);",
					"\tvec2 slope = vec2($heightmap(uv+vec2(dx, 0.0))-v, $heightmap(uv+vec2(0.0, dx))-v);",
					"\tfloat slope_strength = length(slope)*$size;",
					"\tvec2 norm_slope =  (slope_strength == 0.0) ? vec2(0.0, 1.0) : normalize(slope);",
					"\tvec2 e = dx*norm_slope;",
					"\tvec4 rv = vec4(0.0);",
					"\tfloat sum = 0.0;",
					"\tfloat sigma = max($sigma*slope_strength, 0.0001);",
					"\tfor (float i = 0.0; i <= 50.0; i += 1.0) {",
					"\t\tfloat coef = exp(-0.5*(pow(i/sigma, 2.0)))/(6.28318530718*sigma*sigma);",
					"\t\trv += $in(uv+i*e)*coef;",
					"\t\tsum += coef;",
					"\t}",
					"\treturn rv/sum;",
					"}"
				],
				"name": "Slope Blur",
				"outputs": [
					{
						"rgba": "$(name)_fct($uv)",
						"type": "rgba"
					}
				],
				"parameters": [
					{
						"default": 9,
						"first": 4,
						"label": "Size",
						"last": 12,
						"name": "size",
						"type": "size"
					},
					{
						"control": "None",
						"default": 0.5,
						"label": "Sigma",
						"max": 50,
						"min": 0,
						"name": "sigma",
						"step": 0.1,
						"type": "float"
					}
				]
			},
			"type": "shader"
		},
		{
			"name": "buffer_2",
			"node_position": {
				"x": -392.952209,
				"y": -115.576294
			},
			"parameters": {
				"lod": 0,
				"size": 10
			},
			"seed": 42757,
			"type": "buffer"
		}
	],
	"parameters": {
		"param0": 10,
		"param1": 30
	},
	"seed_int": 0,
	"shortdesc": "Slope blur",
	"type": "graph"
}