{
	"name": "sdf3d_pyramid",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"axis": 1,
		"r": 0.4,
		"b": 0.3
	},
	"seed_int": 0,
	"shader_model": {
		"code": "",
		"global": [
			"// The MIT License, Copyright © 2019 Inigo Quilez",
			"// https://www.shadertoy.com/view/Ws3SDl",
			"float sdPyramid(vec3 p, float h) {",
			"\tif (p.y <= 0.0)",
			"\t\treturn length(max(abs(p)-vec3(0.5,0.0,0.5),0.0));",
			"\tfloat m2 = h*h + 0.25;",
			"\tp.xz = abs(p.xz);",
			"\tp.xz = (p.z>p.x) ? p.zx : p.xz;",
			"\tp.xz -= 0.5;",
			"\tvec3 q = vec3( p.z, h*p.y-0.5*p.x, h*p.x+0.5*p.y);  ",
			"\tfloat s = max(-q.x,0.0);",
			"\tfloat t = clamp( (q.y-0.5*q.x)/(m2+0.25), 0.0, 1.0 );",
			"\tfloat a = m2*(q.x+s)*(q.x+s) + q.y*q.y;",
			"\tfloat b = m2*(q.x+0.5*t)*(q.x+0.5*t) + (q.y-m2*t)*(q.y-m2*t);",
			"\tfloat d2 = max(-q.y,q.x*m2+q.y*0.5) < 0.0 ? 0.0 : min(a,b);",
			"\treturn sqrt( (d2+q.z*q.z)/m2 ) * sign(max(q.z,-p.y));",
			"}",
			""
		],
		"inputs": [

		],
		"instance": "",
		"longdesc": "Generates a pyramid as a signed distance function",
		"name": "Pyramid",
		"outputs": [
			{
				"longdesc": "Shows the pyramid",
				"sdf3d": "sdPyramid(0.5*($axis-vec3(0.0, -$r, 0.0))/$b, $r/$b)*$b*2.0",
				"shortdesc": "Output",
				"type": "sdf3d"
			}
		],
		"parameters": [
			{
				"default": 2,
				"label": "Axis",
				"name": "axis",
				"type": "enum",
				"values": [
					{
						"name": "X",
						"value": "$uv.yxz"
					},
					{
						"name": "Y",
						"value": "-$uv"
					},
					{
						"name": "Z",
						"value": "$uv.xzy"
					}
				]
			},
			{
				"control": "Radius1.r",
				"default": 0.5,
				"label": "Height",
				"longdesc": "The height of the pyramid",
				"max": 1,
				"min": 0,
				"name": "r",
				"shortdesc": "Height",
				"step": 0.01,
				"type": "float"
			},
			{
				"control": "None",
				"default": 0.5,
				"label": "Radius",
				"max": 1.0,
				"min": 0.0,
				"name": "b",
				"step": 0.1,
				"type": "float"
			}
		],
		"shortdesc": "Pyramid"
	},
	"type": "shader"
}