{
	"name": "wavelet_noise",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"frequency": 2,
		"iterations": 3,
		"offset": 0,
		"persistence": 0.5,
		"scale_x": 1,
		"scale_y": 1,
		"type": 0
	},
	"seed_int": 1742167584,
	"shader_model": {
		"code": "",
		"global": [
			"float wavelet(vec2 uv, vec2 size, float s, float frequency, float offset) {",
			"\tuv = mod(uv, size);",
			"\tvec2 seed = fract(floor(uv)*0.1236754+vec2(s));",
			"\tuv = fract(uv);",
			"\tvec2 ruv = uv-0.5;",
			"\tfloat a = rand(seed)*6.28;",
			"\tfloat ca = cos(a);",
			"\tfloat sa = sin(a);",
			"\truv = vec2(ca*ruv.x + sa*ruv.y, -sa*ruv.x + ca*ruv.y);",
			"\treturn (0.5*sin(ruv.x*6.28*frequency+offset)+0.5)*max(0.0, 1.0-2.0*length(uv-vec2(0.5)));",
			"}",
			"",
			"float wavelet_noise(vec2 uv, vec2 size, int iterations, float persistence, float seed, float frequency, float offset, float type) {",
			"\tfloat rv = 0.0;",
			"\tfloat acc = 0.0;",
			"\tvec2 seed2 = rand2(vec2(seed));",
			"\tvec2 local_uv = uv * size;",
			"\tfloat q = 1.0;",
			"\tfor (int i = 0; i < iterations; ++i) {",
			"\t\trv += q*wavelet(local_uv, size, seed, frequency, offset);",
			"\t\trv += q*wavelet(local_uv+vec2(0.5), size, seed+0.1, frequency, offset);",
			"\t\tacc += q;",
			"\t\tif (type > 0.0) {",
			"\t\t\tlocal_uv += type*uv;",
			"\t\t\tsize += vec2(type);",
			"\t\t} else {",
			"\t\t\tlocal_uv *= -type;",
			"\t\t\tsize *= -type;",
			"\t\t}",
			"\t\tlocal_uv += seed2; ",
			"\t\tseed2 = rand2(seed2);",
			"\t\tq *= persistence;",
			"\t\tseed += 0.1;",
			"\t}",
			"\treturn rv / acc;",
			"}"
		],
		"inputs": [

		],
		"instance": "",
		"longdesc": "Generates several octaves of grayscale wavelet noise",
		"name": "Wavelet Noise",
		"outputs": [
			{
				"f": "wavelet_noise($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed), $frequency, $offset, $type)",
				"longdesc": "Shows a grayscale wavelet noise",
				"shortdesc": "Output",
				"type": "f"
			}
		],
		"parameters": [
			{
				"default": 4,
				"label": "Type",
				"name": "type",
				"type": "enum",
				"values": [
					{
						"name": "Add 1",
						"value": "1"
					},
					{
						"name": "Add 2",
						"value": "2"
					},
					{
						"name": "Add 3",
						"value": "3"
					},
					{
						"name": "Mult 2",
						"value": "-2"
					},
					{
						"name": "Mult 3",
						"value": "-3"
					}
				]
			},
			{
				"control": "None",
				"default": 4,
				"label": "Scale X",
				"longdesc": "The scale along the X axis",
				"max": 32,
				"min": 1,
				"name": "scale_x",
				"shortdesc": "Scale.x",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 4,
				"label": "Scale Y",
				"longdesc": "The scale along the Y axis",
				"max": 32,
				"min": 1,
				"name": "scale_y",
				"shortdesc": "Scale.y",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 3,
				"label": "Iterations",
				"longdesc": "The number of octaves (higher values might affect performance)",
				"max": 10,
				"min": 1,
				"name": "iterations",
				"shortdesc": "Octaves",
				"step": 1,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.5,
				"label": "Persistence",
				"longdesc": "The persistence between two consecutive octaves",
				"max": 1,
				"min": 0,
				"name": "persistence",
				"shortdesc": "Persistence",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 1,
				"label": "Frequency",
				"max": 2,
				"min": 0,
				"name": "frequency",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0,
				"label": "Offset",
				"max": 1,
				"min": -1,
				"name": "offset",
				"step": 0.01,
				"type": "float"
			}
		],
		"shortdesc": "Wavelet Noise"
	},
	"type": "shader"
}