{
	"name": "seven_segment2",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"bevel": 0,
		"digits": 1,
		"n": 8,
		"s": 1,
		"sl": 0.9,
		"spacing": 0.1,
		"st": 0.3
	},
	"seed_int": 0,
	"shader_model": {
		"code": "",
		"global": [
			"float m(vec4 a, vec4 b)",
			"{",
			"\treturn max(max(max(a.x,a.y),max(a.z,a.w)),max(max(b.x,b.y),max(b.z,b.w)));",
			"}",
			"",
			"vec4 fs(vec2 p,float s, float st, float sl, bool is_top)",
			"{",
			"\tsl = (1.0 - sl)/2.0; st /= 2.0;",
			"\tsl = clamp(sl, 0.0,1.0);",
			"",
			"\tp = 2.5*(1.0/s)*(p - 0.5)-vec2(0.0, is_top ? -0.5 : 0.5);",
			"\tvec2 p1 = p; vec2 p2 = p;",
			"\t",
			"\tp = abs(p)-0.5;",
			"\tvec4 d = vec4(min(st - abs(max(p.x, p.y) * -1.0),",
			"\t\tmin(-dot(p, normalize(vec2(1.0, 1.0))),",
			"\t\tabs(dot(p, normalize(vec2(1.0, -1.0))))) - sl));",
			"",
			"\tp1.x = abs(p1.x);",
			"\tp2.y = abs(p2.y);",
			"",
			"\tfloat q1 = -dot(p1,vec2(1.0,1.0));",
			"\tfloat q2 = -dot(p2,vec2(-1.0,1.0));",
			"\tfloat q3 = dot(p1,vec2(-1.0,1.0));",
			"\tfloat q4 = -dot(p2,vec2(1.0,1.0));",
			"\t",
			"\treturn min(d,vec4(q1,q2,q3,q4));",
			"}",
			"",
			"float ssd(vec2 p, float s, float st, float sl, float bevel, int num)",
			"{",
			"\tvec4 a = fs(p,s,st,sl,true);",
			"\tvec4 b = fs(p,s,st,sl,false);",
			"\t",
			"\tfloat d;",
			"\t",
			"\tvec4 x = vec4(0.0);",
			"\t",
			"\tif (num == 0) d = m(vec4(a.xyw,b.y),vec4(b.zw,x.xx));",
			"\tif (num == 1) d = m(vec4(a.y,b.y,x.xx),x);",
			"\tif (num == 2) d = m(vec4(a.xyz,b.w),vec4(b.z,x.xxx));",
			"\tif (num == 3) d = m(vec4(a.xyz,b.y),vec4(b.z,x.xxx));",
			"\tif (num == 4) d = m(vec4(a.yzw,b.y),x);",
			"\tif (num == 5) d = m(vec4(a.xwz,b.y),vec4(b.z,x.xxx));",
			"\tif (num == 6) d = m(vec4(a.xwz,b.y),vec4(b.zw,x.xx));",
			"\tif (num == 7) d = m(vec4(a.xy,b.y,x.x),x);",
			"\tif (num == 8) d = m(a,b);",
			"\tif (num == 9) d = m(a,vec4(b.yz,x.xx));",
			"\t",
			"\treturn clamp(d/max(bevel, 0.00001), 0.0, 1.0);",
			"}",
			"",
			"float ssd_multi(vec2 p, float s, float st, float sl, float bevel, int num, int digits, float spacing)",
			"{",
			"\tfloat v = 0.0;",
			"\twhile (num > 0 || digits > 0) {",
			"\t\tv = max(v, ssd(p, s, st, sl, bevel, num % 10));",
			"\t\tnum /= 10;",
			"\t\tp.x += (spacing+0.5)*s;",
			"\t\tdigits -= 1;",
			"\t}",
			"\treturn v;",
			"}",
			""
		],
		"inputs": [
			{
				"default": "1.0",
				"label": "3:",
				"longdesc": "Map that affects the nnumber parameter",
				"name": "number_map",
				"shortdesc": "Number Map",
				"type": "f"
			},
			{
				"default": "1.0",
				"label": "6:",
				"longdesc": "Map that affects the bevel parameter",
				"name": "bevel_map",
				"shortdesc": "Bevel Map",
				"type": "f"
			}
		],
		"instance": "",
		"name": "Seven Segment Display",
		"outputs": [
			{
				"f": "ssd_multi($uv, $s, $st, $sl, $bevel*$bevel_map($uv), int($n*$number_map($uv)), int($digits), $spacing)",
				"shortdesc": "Output",
				"type": "f"
			}
		],
		"parameters": [
			{
				"control": "None",
				"default": 0.3,
				"label": "Thickness",
				"max": 1,
				"min": 0,
				"name": "st",
				"shortdesc": "Segments thickness",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.9,
				"label": "Length",
				"max": 1,
				"min": 0,
				"name": "sl",
				"shortdesc": "Segments length",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 8,
				"label": "Number",
				"max": 100,
				"min": 0,
				"name": "n",
				"shortdesc": "Number for the display",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Digits",
				"longdesc": "Minimum number of digits of the display",
				"max": 9,
				"min": 1,
				"name": "digits",
				"shortdesc": "Digits",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Scale",
				"longdesc": "Scale of the display",
				"max": 1,
				"min": 0,
				"name": "s",
				"shortdesc": "Scale",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Bevel",
				"max": 1,
				"min": 0,
				"name": "bevel",
				"shortdesc": "Width of the edge of each segment",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Spacing",
				"longdesc": "Space between digits",
				"max": 0.5,
				"min": 0,
				"name": "spacing",
				"shortdesc": "Spacing",
				"step": 0.01,
				"type": "float"
			}
		],
		"shortdesc": "Simple 7-seg number display"
	},
	"type": "shader"
}
