{
	"name": "scratches",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"angle": 0,
		"layers": 5,
		"length": 0.25,
		"randomness": 0.3,
		"waviness": 0.3,
		"width": 0.4
	},
	"seed_int": 0,
	"shader_model": {
		"code": "",
		"global": [
			"float scratch(vec2 uv, vec2 size, float waviness, float angle, float randomness, vec2 seed) {",
			"\tfloat subdivide = floor(1.0/size.x);",
			"\tfloat cut = size.x*subdivide;",
			"\tuv *= subdivide;",
			"\tvec2 r1 = rand2(floor(uv)+seed);",
			"\tvec2 r2 = rand2(r1);",
			"\tuv = fract(uv);",
			"\tvec2 border = 10.0*min(fract(uv), 1.0-fract(uv));",
			"\tuv = 2.0*uv-vec2(1.0);",
			"\tfloat a = 6.28318530718*(angle+(r1.x-0.5)*randomness);",
			"\tfloat c = cos(a);",
			"\tfloat s = sin(a);",
			"\tuv = vec2(c*uv.x+s*uv.y, s*uv.x-c*uv.y);",
			"\tuv.y += 2.0*r1.y-1.0;",
			"\tuv.y += 0.5*waviness*cos(2.0*uv.x+6.28318530718*r2.y);",
			"\tuv.x /= cut;",
			"\tuv.y /= subdivide*size.y;",
			"\treturn min(border.x, border.y)*(1.0-uv.x*uv.x)*max(0.0, 1.0-1000.0*uv.y*uv.y);",
			"}",
			"",
			"float scratches(vec2 uv, int layers, vec2 size, float waviness, float angle, float randomness, vec2 seed) {",
			"\tfloat v = 0.0;",
			"\tfor (int i = 0; i < layers; ++i) {",
			"\t\tseed = rand2(seed);",
			"\t\tv = max(v, scratch(fract(uv+seed), size, waviness, angle/360.0, randomness, seed));",
			"\t}",
			"\treturn v;",
			"}",
			""
		],
		"inputs": [

		],
		"instance": "",
		"longdesc": "Draws white scratches on a black background",
		"name": "Scratches",
		"outputs": [
			{
				"f": "scratches($uv, int($layers), vec2($length, $width), $waviness, $angle, $randomness, vec2(float($seed), 0.0))",
				"longdesc": "Shows white scratches on a black background",
				"shortdesc": "Output",
				"type": "f"
			}
		],
		"parameters": [
			{
				"control": "None",
				"default": 0.25,
				"label": "Length",
				"longdesc": "The length of scratches (the shorter the scratches,the more they will be)",
				"max": 1,
				"min": 0.1,
				"name": "length",
				"shortdesc": "Length",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.5,
				"label": "Width",
				"longdesc": "The width of scratches",
				"max": 1,
				"min": 0.1,
				"name": "width",
				"shortdesc": "Width",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 4,
				"label": "Layers",
				"longdesc": "The number of scratches layers",
				"max": 10,
				"min": 1,
				"name": "layers",
				"shortdesc": "Layers",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.5,
				"label": "Waviness",
				"longdesc": "The waviness of scratches",
				"max": 1,
				"min": 0,
				"name": "waviness",
				"shortdesc": "Waviness",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Angle",
				"longdesc": "The average angle of the scratches (0 generates horizontal scratches)",
				"max": 180,
				"min": -180,
				"name": "angle",
				"shortdesc": "Angle",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.5,
				"label": "Randomness",
				"longdesc": "The randomness of the scratches angles",
				"max": 1,
				"min": 0,
				"name": "randomness",
				"shortdesc": "Randomness",
				"step": 0.01,
				"type": "float"
			}
		]
	},
	"type": "shader"
}