group = "Terrain"
display_name = "Terrain Base Normal"
depends_on = ["core/stingray_renderer/output_nodes/terrain_base"]

inputs = {
//	"e3419eb2-3635-4586-b58c-89ffd88d20d5" = { name = "speed_v" display_name = "Speed V" is_required = false type = { scalar: ["HAS_SPEED_V"] }}
}

imports = {
	uv = {
		type = "float2"
		domain = "vertex"
		output_channel = "terrain_uv"
	}

	terrain_size = {
		type = "float3"
		domain = "global"
		source = "engine"
	}
}

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

code_blocks = {	
	default = {
		language = "hlsl"

		code = """
			#if defined(RENDERER_D3D11) || defined(RENDERER_D3D12) || defined(RENDERER_GNM)
				float2 res;
				TEXTURE_NAME(hmap).GetDimensions(res.x, res.y);
				float2 inv_hmap_size = 1.0/res;
			#endif
		
			float3 n = normal_from_hmap(hmap, uv, inv_hmap_size, terrain_size.z);	
			RESULT(n);
		"""
	}
}
