{
	"name": "perlin",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"iterations": 3,
		"persistence": 0.5,
		"scale_x": 4,
		"scale_y": 4
	},
	"shader_model": {
		"global": "float perlin(vec2 uv, vec2 size, int iterations, float persistence, int seed) {\n\tvec2 seed2 = rand2(vec2(float(seed), 1.0-float(seed)));\n    float rv = 0.0;\n    float coef = 1.0;\n    float acc = 0.0;\n    for (int i = 0; i < iterations; ++i) {\n    \tvec2 step = vec2(1.0)/size;\n\t\tvec2 xy = floor(uv*size);\n        float f0 = rand(seed2+mod(xy, size));\n        float f1 = rand(seed2+mod(xy+vec2(1.0, 0.0), size));\n        float f2 = rand(seed2+mod(xy+vec2(0.0, 1.0), size));\n        float f3 = rand(seed2+mod(xy+vec2(1.0, 1.0), size));\n        vec2 mixval = smoothstep(0.0, 1.0, fract(uv*size));\n        rv += coef * mix(mix(f0, f1, mixval.x), mix(f2, f3, mixval.x), mixval.y);\n        acc += coef;\n        size *= 2.0;\n        coef *= persistence;\n    }\n    \n    return rv / acc;\n}\n",
		"instance": "",
		"name": "Perlin",
		"outputs": [
			{
				"f": "perlin($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))"
			}
		],
		"parameters": [
			{
				"default": 4,
				"label": "Scale X",
				"max": 32,
				"min": 1,
				"name": "scale_x",
				"step": 1,
				"type": "float",
				"widget": "spinbox"
			},
			{
				"default": 4,
				"label": "Scale Y",
				"max": 32,
				"min": 1,
				"name": "scale_y",
				"step": 1,
				"type": "float",
				"widget": "spinbox"
			},
			{
				"default": 3,
				"label": "Iterations",
				"max": 10,
				"min": 1,
				"name": "iterations",
				"step": 1,
				"type": "float",
				"widget": "spinbox"
			},
			{
				"default": 0.5,
				"label": "Persistance",
				"max": 1,
				"min": 0,
				"name": "persistence",
				"step": 0.05,
				"type": "float",
				"widget": "spinbox"
			}
		]
	}
}