1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#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;
}