Harbor

branch main
showing the latest snapshot on main
basic_fragment.msl 676 B · Plain text
shader/tests/golden/basic_fragment.msl 0644 Raw
#include <metal_stdlib>
using namespace metal;

struct _shade_Input {
	float2 uv [[user(locn0)]];
	float3 normal [[user(locn1)]];
};

struct _shade_Output {
	float4 _value [[user(locn0)]];
};

fragment _shade_Output shade(_shade_Input input [[stage_in]],
	texture2d<float> material_tex_tex [[texture(0)]],
	sampler material_tex_samp [[sampler(0)]]) {
	_shade_Output __luma_output;
	float4 albedo = material_tex_tex.sample(material_tex_samp, input.uv);
	float3 n = normalize(input.normal);
	float3 light_dir = normalize(float3(1.0, 1.0, 0.5));
	float light = max(dot(n, light_dir), 0.0);
	__luma_output._value = float4((albedo.rgb * light), albedo.a);
	return __luma_output;
}