1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- Test @varying struct: shared between vertex output and fragment input
-- Fragment input should strip @builtin(position)
-- Uses auto-location and auto-binding
struct VertexInput
position: vec3
uv: vec2
end
@varying
struct Interpolated
@builtin(position) position: vec4
uv: vec2
normal: vec3
end
struct FragmentOutput
color: vec4
end
struct Uniforms
mvp: mat4
end
uniform uniforms: Uniforms
@entry(vertex)
function vs_main(input: VertexInput) -> Interpolated
let clip_pos = uniforms.mvp * vec4(input.position, 1.0)
return Interpolated {
position = clip_pos,
uv = input.uv,
normal = vec3(0.0, 1.0, 0.0),
}
end
@entry(fragment)
function fs_main(input: Interpolated) -> FragmentOutput
return FragmentOutput {
color = vec4(input.uv, 0.0, 1.0),
}
end