group = "Transform"
display_name = "World To Tangent Space"
depends_on = [
	"core/stingray_renderer/output_nodes/standard_base"
	"core/stingray_renderer/output_nodes/terrain_base"
]

inputs = {
	"f72597c4-7487-419a-affb-df690e6582e1" = { name = "v" display_name = "Vector" type = "float3" }
}

defines = ["NEEDS_TANGENT_SPACE"]

imports = {
	tsm0 = {
		type = "float3"
		domain = "vertex"
		output_channel = "tsm0"
	}
	tsm1 = {
		type = "float3"
		domain = "vertex"
		output_channel = "tsm1"
	}
	tsm2 = {
		type = "float3"
		domain = "vertex"
		output_channel = "tsm2"
	}
}

output = {
	type = { typeof: "v" }
}

code = """
	float3 res = float3(
		dot(v, float3(tsm0.x, tsm1.x, tsm2.x)),
		dot(v, float3(tsm0.y, tsm1.y, tsm2.y)),
		dot(v, float3(tsm0.z, tsm1.z, tsm2.z)));
	RESULT(normalize(res));
"""
