{
	"name": "cairo",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"angle": 30,
		"round": 0.5,
		"sx": 4,
		"sy": 4
	},
	"seed_int": 0,
	"shader_model": {
		"code": "",
		"global": [
			"float cairo_round(vec2 uv, float angle, float k) {",
			"\tvec2 cell = floor(uv);",
			"\tfloat ca = cos(angle);",
			"\tfloat sa = sin(angle);",
			"\tvec2 corner = fract(uv)-0.5;",
			"\tuv = 0.5-abs(corner);",
			"\tuv = mix(uv, uv.yx, mod(cell.x+cell.y, 2.0));",
			"\tfloat side = dot(vec2(-sa, ca), uv);",
			"\tfloat d1 = abs(side);",
			"\tfloat d2 = abs(dot(vec2(-sa, ca), mix(vec2(uv.x, 1.0-uv.y), vec2(1.0-uv.x, uv.y), step(side, 0.0))));",
			"\tfloat d3 = abs(dot(vec2(ca, sa), uv));",
			"\tfloat d4 = mix(0.5-uv.x, 0.5-uv.y, step(side, 0.0));",
			"\treturn clamp(-log2(exp2(-k*d1)+exp2(-k*d2)+exp2(-k*d3)+exp2(-k*d4))/k, 0.0, 1.0);",
			"}",
			"",
			"vec4 cairo_bbox(vec2 uv, float angle) {",
			"\tvec2 cell = floor(uv);",
			"\tfloat cell_type = mod(cell.x+cell.y, 2.0);",
			"\tfloat ca = cos(angle);",
			"\tfloat sa = sin(angle);",
			"\tfloat l = 0.0;",
			"\tfloat r = 1.0;",
			"\tfloat b = 0.0;",
			"\tfloat t = 1.0;",
			"\tvec2 corner = fract(uv)-0.5;",
			"\tuv = 0.5-abs(corner);",
			"\tuv = mix(uv, uv.yx, cell_type);",
			"\tfloat side = dot(vec2(-sa, ca), uv);",
			"\tfloat ta = tan(angle);",
			"\tfloat c = min(0.5, 0.5/ta);",
			"\tfloat s = min(0.5, 0.5*ta);",
			"\tif (cell_type > 0.5) {",
			"\t\tif (side > 0.0) {",
			"\t\t\tif (corner.y > 0.0) {",
			"\t\t\t\tt = 1.0+s;",
			"\t\t\t\tb = 1.0-c;",
			"\t\t\t} else {",
			"\t\t\t\tt = c;",
			"\t\t\t\tb = -s;",
			"\t\t\t}",
			"\t\t} else {",
			"\t\t\tif (corner.x > 0.0) {",
			"\t\t\t\tl = 1.0-s;",
			"\t\t\t\tr = 1.0+c;",
			"\t\t\t} else {",
			"\t\t\t\tl = -c;",
			"\t\t\t\tr = s;",
			"\t\t\t}",
			"\t\t}",
			"\t} else {",
			"\t\tif (side > 0.0) {",
			"\t\t\tif (corner.x > 0.0) {",
			"\t\t\t\tl = 1.0-c;",
			"\t\t\t\tr = 1.0+s;",
			"\t\t\t} else {",
			"\t\t\t\tl = -s;",
			"\t\t\t\tr = c;",
			"\t\t\t}",
			"\t\t} else {",
			"\t\t\tif (corner.y > 0.0) {",
			"\t\t\t\tt = 1.0+c;",
			"\t\t\t\tb = 1.0-s;",
			"\t\t\t} else {",
			"\t\t\t\tt = s;",
			"\t\t\t\tb = -c;",
			"\t\t\t}",
			"\t\t}",
			"\t}",
			"\tfloat d1 = abs(side);",
			"\tfloat d3 = abs(dot(vec2(ca, sa), uv));",
			"\tfloat d4 = mix(0.5-uv.x, 0.5-uv.y, step(side, 0.0));",
			"\treturn vec4(cell.x+l, cell.y+b, r-l, t-b);",
			"}",
			""
		],
		"inputs": [

		],
		"instance": "",
		"longdesc": "Draws a grayscale Cairo tiles pattern",
		"name": "Cairo",
		"outputs": [
			{
				"f": "cairo_round($uv*vec2($sx, $sy), $angle*0.01745329251, 200.0-190.0*$round)",
				"longdesc": "Shows the grayscale pattern",
				"shortdesc": "Output",
				"type": "f"
			},
			{
				"fill": "floor(8192.0*fract(cairo_bbox($uv*vec2($sx, $sy), $angle*0.01745329251)/vec2($sx, $sy).xyxy))/8192.0",
				"longdesc": "An output that should be plugged into a Fill companion node",
				"shortdesc": "Fill",
				"type": "fill"
			}
		],
		"parameters": [
			{
				"control": "None",
				"default": 4,
				"label": "Size X",
				"longdesc": "The number of columns of the pattern (odd values do not tile correctly)",
				"max": 64,
				"min": 1,
				"name": "sx",
				"shortdesc": "Size.x",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 4,
				"label": "Size Y",
				"longdesc": "The number of rows of the pattern (odd values do not tile correctly)",
				"max": 64,
				"min": 1,
				"name": "sy",
				"shortdesc": "Size.y",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 30,
				"label": "Angle",
				"longdesc": "The angle of the pentagons that form the pattern",
				"max": 90,
				"min": 0,
				"name": "angle",
				"shortdesc": "Angle",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Round",
				"longdesc": "The roundness of the corners",
				"max": 1,
				"min": 0,
				"name": "round",
				"shortdesc": "Round",
				"step": 0.01,
				"type": "float"
			}
		],
		"shortdesc": "Cairo tiles pattern"
	},
	"type": "shader"
}