group = "Skydome"
display_name = "Cloud Map"
depends_on = ["core/stingray_renderer/output_nodes/skydome_base"]

inputs = {
	"72b20d47-88d1-48a4-99f5-819433b2d601" = { name = "texcoord" display_name = "UV" type = "vector2" domain = "pixel" }
}

domain = "pixel"
output = {
	type = "float4"
}

options = {
	"49e69d88-c7ce-4223-b3ce-149c0bf72a0a" = "ADDRESS_CLAMP"
	"80c5c862-1d7e-4fc8-acfb-6fed1cd608f2" = "ADDRESS_WRAP"
	"d293ab9d-8dda-4a7d-9114-0ff75dfe2378" = "FILTER_LINEAR"
	"b780e0f4-527f-43c1-a39c-860e17417114" = "FILTER_POINT"
	"04dac948-1138-4283-861f-20c70a20548f" = "FILTER_ANISOTROPIC"
	"63b1e469-c7c0-4a32-b5da-5cf14d304ca0" = "SRGB"
    "c3acf080-6620-435c-aeca-1f6ba47ee1b5" = "LINEAR"
    "3f78e559-e91b-4b93-a68b-0140a240193c" = "RGBM_DECODE"
}

ui = [
	{
		type = "drop_down"
		display_name = "Encoding"
		options = {
			"Linear Color" 	= "c3acf080-6620-435c-aeca-1f6ba47ee1b5"
			"sRGB Color" 	= "63b1e469-c7c0-4a32-b5da-5cf14d304ca0"
			"RGBM Color" 	= "3f78e559-e91b-4b93-a68b-0140a240193c"
		}
		default = "63b1e469-c7c0-4a32-b5da-5cf14d304ca0"
	}
	{
		type = "drop_down"
		display_name = "Address mode"
		options = {
			"Clamp" = "49e69d88-c7ce-4223-b3ce-149c0bf72a0a"
			"Wrap" 	= "80c5c862-1d7e-4fc8-acfb-6fed1cd608f2"
		}
		default = "80c5c862-1d7e-4fc8-acfb-6fed1cd608f2"
	}
	{
		type = "drop_down"
		display_name = "Filter mode"
		options = {
			"Anisotropic" 	= "04dac948-1138-4283-861f-20c70a20548f"
			"Linear" 		= "c3acf080-6620-435c-aeca-1f6ba47ee1b5"
			"Point" 		= "b780e0f4-527f-43c1-a39c-860e17417114"
		}
		default = "04dac948-1138-4283-861f-20c70a20548f"
	}
]

code_blocks = {
	default = {
		language = "hlsl"
		samplers = {
			skydome_cloud_map = {
				sampler_state = "core/shader_nodes/graph_common#default_node_sampler"
				source = "resource_set"
				slot_name = "skydome_cloud_map"
				type = "2d"
			}
		}

		code = """
			float4 result = TEX2D(skydome_cloud_map, texcoord);
				
			#if defined(RENDERER_GL) && defined(SRGB)
				result = fast_gamma_to_linear_rgba(result);
			#elif defined(RGBM_DECODE)
				result = float4(rgbm_decode(result), 0);
			#endif

			RESULT(result);
		"""
	}
}
