{
	"name": "runes",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"columns": 4,
		"rows": 4
	},
	"seed_int": 0,
	"shader_model": {
		"code": "",
		"global": [
			"float ThickLine(vec2 uv, vec2 posA, vec2 posB, float radiusInv)",
			"{",
			"\treturn clamp(1.1-20.0*sdLine(uv, posA, posB).x, 0.0, 1.0);",
			"}",
			"",
			"// makes a rune in the 0..1 uv space. Seed is which rune to draw.",
			"// passes back gray in x and derivates for lighting in yz",
			"float Rune(vec2 uv, float s) {",
			"\tfloat finalLine = 0.0;",
			"\tvec2 seed = floor(uv)-rand2(vec2(s));",
			"\tuv = fract(uv);",
			"\tfor (int i = 0; i < 4; i++)\t// number of strokes",
			"\t{",
			"\t\tvec2 posA = rand2(floor(seed+0.5));",
			"\t\tvec2 posB = rand2(floor(seed+1.5));",
			"\t\tseed += 2.0;",
			"\t\t// expand the range and mod it to get a nicely distributed random number - hopefully. :)",
			"\t\tposA = fract(posA * 128.0);",
			"\t\tposB = fract(posB * 128.0);",
			"\t\t// each rune touches the edge of its box on all 4 sides",
			"\t\tif (i == 0) posA.y = 0.0;",
			"\t\tif (i == 1) posA.x = 0.999;",
			"\t\tif (i == 2) posA.x = 0.0;",
			"\t\tif (i == 3) posA.y = 0.999;",
			"\t\t// snap the random line endpoints to a grid 2x3",
			"\t\tvec2 snaps = vec2(2.0, 3.0);",
			"\t\tposA = (floor(posA * snaps) + 0.5) / snaps;\t// + 0.5 to center it in a grid cell",
			"\t\tposB = (floor(posB * snaps) + 0.5) / snaps;",
			"\t\t//if (distance(posA, posB) < 0.0001) continue;\t// eliminate dots.",
			"\t\t// Dots (degenerate lines) are not cross-GPU safe without adding 0.001 - divide by 0 error.",
			"\t\tfinalLine = max(finalLine, ThickLine(uv, posA, posB + 0.001, 20.0));",
			"\t}",
			"\treturn finalLine;",
			"}",
			"",
			"",
			""
		],
		"includes": [
			"sdline2"
		],
		"inputs": [

		],
		"instance": "",
		"longdesc": "Generates a grid filled with random runes",
		"name": "Runes",
		"outputs": [
			{
				"f": "Rune(vec2($columns, $rows)*$uv, float($seed))",
				"longdesc": "A grayscale image showing random runes.",
				"shortdesc": "Output",
				"type": "f"
			}
		],
		"parameters": [
			{
				"control": "None",
				"default": 0,
				"label": "Size X",
				"longdesc": "The number of columns of the grid",
				"max": 32,
				"min": 2,
				"name": "columns",
				"shortdesc": "Size.x",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Size Y",
				"longdesc": "The number of rows of the grid",
				"max": 32,
				"min": 2,
				"name": "rows",
				"shortdesc": "Size.y",
				"step": 1,
				"type": "float"
			}
		],
		"shortdesc": "Simple runes"
	},
	"type": "shader"
}