{
	"name": "convert_colorspace",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"parameters": {
		"colorspace": 0,
		"direction": 0
	},
	"seed_int": 0,
	"shader_model": {
		"code": "",
		"global": "vec3 from_rgb_to_rgb(vec3 c) {return c;}\nvec3 to_rgb_from_rgb(vec3 c) {return c;}\n\nvec3 from_rgb_to_hsv(vec3 c) {\n\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n\tvec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);\n\tvec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);\n\n\tfloat d = q.x - min(q.w, q.y);\n\tfloat e = 1.0e-10;\n\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 to_rgb_from_hsv(vec3 c) {\n\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n\treturn c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n// Matrix coefficients taken from https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.709_conversion\nvec3 from_rgb_to_yuv(vec3 c) {\n\treturn c * mat3(\n\t\tvec3( 0.2126,  0.7152,  0.0722),\n\t\tvec3(-0.1146, -0.3854,  0.5),\n\t\tvec3( 0.5,    -0.4542, -0.0458)\n\t);\n}\nvec3 to_rgb_from_yuv(vec3 c) {\n\treturn c * mat3(\n\t\tvec3(1.0,  0.0,     1.5748),\n\t\tvec3(1.0, -0.1873, -0.4681),\n\t\tvec3(1.0,  1.8556,  0.0)\n\t);\n}\n",
		"inputs": [
			{
				"default": "vec4(1.0, 1.0, 1.0, 1.0)",
				"label": "",
				"name": "input",
				"type": "rgba"
			}
		],
		"instance": "",
		"name": "Convert Colorspace",
		"outputs": [
			{
				"rgba": "vec4($(direction)_$(colorspace)($input($uv).rgb), $input($uv).a)",
				"type": "rgba"
			}
		],
		"parameters": [
			{
				"default": 0,
				"label": "",
				"name": "direction",
				"type": "enum",
				"values": [
					{
						"name": "Convert from RGB to",
						"value": "from_rgb_to"
					},
					{
						"name": "Convert to RGB from",
						"value": "to_rgb_from"
					}
				]
			},
			{
				"default": 0,
				"label": "",
				"name": "colorspace",
				"type": "enum",
				"values": [
					{
						"name": "RGB (no-op)",
						"value": "rgb"
					},
					{
						"name": "HSV",
						"value": "hsv"
					},
					{
						"name": "YUV",
						"value": "yuv"
					}
				]
			}
		]
	},
	"type": "shader"
}