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
-- Basic vertex shader test
-- Uses auto-location numbering and auto-binding
struct VertexInput
position: vec3
normal: vec3
uv: vec2
end
@varying
struct VertexOutput
@builtin(position) position: vec4
uv: vec2
normal: vec3
end
struct Uniforms
model: mat4
view_proj: mat4
normal_mat: mat4
end
uniform uniforms: Uniforms
@entry(vertex)
function transform(input: VertexInput) -> VertexOutput
let pos = input.position
let world_pos = uniforms.model * vec4(pos, 1.0)
let clip_pos = uniforms.view_proj * world_pos
return VertexOutput {
position = clip_pos,
uv = input.uv,
normal = normalize((uniforms.normal_mat * vec4(input.normal, 0.0)).xyz),
}
end