{
	"name": "arc_pavement",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"bevel": 0.2,
		"bricks": 8,
		"mortar": 0.05,
		"repeat": 2,
		"rows": 12
	},
	"seed_int": 0,
	"shader_model": {
		"code": [
			"vec2 $(name_uv)_uv = fract($uv)*vec2($repeat, -1.0);",
			"vec2 $(name_uv)_seed;",
			"vec4 $(name_uv)_ap = arc_pavement($(name_uv)_uv, $rows, $bricks, $(name_uv)_seed);",
			""
		],
		"global": [
			"float pavement(vec2 uv, float bevel, float mortar) {",
			"\tuv = abs(uv-vec2(0.5));",
			"\treturn clamp((0.5*(1.0-mortar)-max(uv.x, uv.y))/max(0.0001, bevel), 0.0, 1.0);",
			"}",
			"",
			"vec4 arc_pavement(vec2 uv, float acount, float lcount, out vec2 seed) {",
			"\tfloat radius = (0.5/sqrt(2.0));",
			"\tfloat uvx = uv.x;",
			"\tuv.x = 0.5*fract(uv.x+0.5)+0.25;",
			"\tfloat center = (uv.x-0.5)/radius;",
			"\tcenter *= center;",
			"\tcenter = floor(acount*(uv.y-radius*sqrt(1.0-center))+0.5)/acount;",
			"\tvec2 v = uv-vec2(0.5, center);",
			"\tfloat cornerangle = 0.85/acount+0.25*PI;",
			"\tfloat acountangle = (PI-2.0*cornerangle)/(lcount+floor(mod(center*acount, 2.0)));",
			"\tfloat angle = mod(atan(v.y, v.x), 2.0*PI);",
			"\tfloat base_angle;",
			"\tfloat local_uvy = 0.5+acount*(length(v)-radius)*(1.66-0.71*cos(1.44*(angle-PI*0.5)));",
			"\tvec2 local_uv;",
			"\tif (angle < cornerangle) {",
			"\t\tbase_angle = 0.25*PI;",
			"\t\tlocal_uv = vec2((angle-0.25*PI)/cornerangle*0.4*acount+0.55, 1.0-local_uvy);",
			"\t\tseed = vec2(fract(center), 0.0);",
			"\t} else if (angle > PI-cornerangle) {",
			"\t\tbase_angle = 0.75*PI;",
			"\t\tlocal_uv = vec2(local_uvy, 0.45-(0.75*PI-angle)/cornerangle*0.4*acount);",
			"\t\tseed = vec2(fract(center), 0.0);",
			"\t} else {",
			"\t\tbase_angle = cornerangle+(floor((angle-cornerangle)/acountangle)+0.5)*acountangle;",
			"\t\tlocal_uv = vec2((angle-base_angle)/acountangle+0.5, 1.0-local_uvy);",
			"\t\tseed = vec2(fract(center), base_angle);",
			"\t}",
			"\tvec2 brick_center = vec2(0.5, center)+radius*vec2(cos(base_angle), sin(base_angle));",
			"\treturn vec4(brick_center.x+uvx-uv.x, brick_center.y, local_uv);",
			"}",
			""
		],
		"inputs": [

		],
		"instance": "",
		"longdesc": "Draws a white shape on a black background",
		"name": "Arc Pavement",
		"outputs": [
			{
				"f": "pavement($(name_uv)_ap.zw, $bevel, 2.0*$mortar)",
				"longdesc": "A grayscale image that shows the bricks pattern",
				"shortdesc": "Bricks pattern",
				"type": "f"
			},
			{
				"longdesc": "A random color for each brick",
				"rgb": "rand3($(name_uv)_seed)",
				"shortdesc": "Random color",
				"type": "rgb"
			},
			{
				"longdesc": "An UV map output for each brick, to be connected to the Map input of a CustomUV node",
				"rgb": "vec3($(name_uv)_ap.zw, 0.0)",
				"shortdesc": "Brick UV",
				"type": "rgb"
			}
		],
		"parameters": [
			{
				"control": "None",
				"default": 2,
				"label": "Repeat:",
				"longdesc": "The number of repetitions of the whole pattern",
				"max": 4,
				"min": 1,
				"name": "repeat",
				"shortdesc": "Repeat",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 8,
				"label": "Rows:",
				"longdesc": "The number of rows",
				"max": 16,
				"min": 4,
				"name": "rows",
				"shortdesc": "Rows",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 8,
				"label": "Bricks:",
				"longdesc": "The number of bricks per row",
				"max": 16,
				"min": 4,
				"name": "bricks",
				"shortdesc": "Bricks",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.1,
				"label": "Mortar:",
				"longdesc": "The width of the space between bricks",
				"max": 0.5,
				"min": 0,
				"name": "mortar",
				"shortdesc": "Mortar",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.1,
				"label": "Bevel:",
				"longdesc": "The width of the edge of each brick",
				"max": 0.5,
				"min": 0,
				"name": "bevel",
				"shortdesc": "Bevel",
				"step": 0.01,
				"type": "float"
			}
		]
	},
	"type": "shader"
}