{
	"name": "brush_triplanar",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"k": 32
	},
	"seed": -42850,
	"shader_model": {
		"code": "",
		"global": "",
		"inputs": [
			{
				"default": "vec4(0.0)",
				"function": true,
				"label": "",
				"name": "in",
				"type": "rgba"
			}
		],
		"instance": [
			"vec4 triplanar_$(name)(vec2 uv, float k) {",
			"\tvec3 p = mesh_aabb_position+texture(mesh_inv_uv_tex, uv).xyz*mesh_aabb_size;",
			"\tvec3 n = 2.0*(texture(mesh_normal_tex, uv).xyz-vec3(0.5));",
			"",
			"\t// project+fetch",
			"\tvec4 x = $in(p.zy);",
			"\tvec4 y = $in(p.zx);",
			"\tvec4 z = $in(p.xy);",
			"",
			"\t// blend factors",
			"\tvec3 w = pow(abs(n), vec3(k));",
			"\t// blend and return",
			"\treturn (x*w.x + y*w.y + z*w.z) / (w.x + w.y + w.z);",
			"}",
			""
		],
		"name": "Triplanar Brush Map",
		"outputs": [
			{
				"rgba": "triplanar_$(name)($uv, $k)",
				"type": "rgba"
			}
		],
		"parameters": [
			{
				"control": "None",
				"default": 1,
				"label": "",
				"max": 32,
				"min": 0,
				"name": "k",
				"step": 0.1,
				"type": "float"
			}
		]
	},
	"type": "shader"
}