]> git.lizzy.rs Git - mt_client.git/blob - assets/shaders/map.wgsl
f6919a97f7af6d2fa6e4f767642a777798f35a51
[mt_client.git] / assets / shaders / map.wgsl
1 // Vertex shader
2
3 struct VertexInput {
4         @location(0) pos: vec3<f32>,
5         @location(1) tex_coords: vec2<f32>,
6 }
7
8 struct VertexOutput {
9         @builtin(position) pos: vec4<f32>,
10         @location(0) tex_coords: vec2<f32>,
11 }
12
13 @group(1) @binding(0) var<uniform> view_proj: mat4x4<f32>;
14 @group(2) @binding(0) var<uniform> model: mat4x4<f32>;
15
16 @vertex
17 fn vs_main(
18         in: VertexInput,
19 ) -> VertexOutput {
20         var out: VertexOutput;
21         out.pos = view_proj * model * vec4<f32>(in.pos, 1.0);
22         out.tex_coords = in.tex_coords;
23         return out;
24 }
25
26 // Fragment shader
27
28 @group(0) @binding(0) var atlas_texture: texture_2d<f32>;
29 @group(0) @binding(1) var atlas_sampler: sampler;
30
31 @fragment
32 fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
33         return textureSample(atlas_texture, atlas_sampler, in.tex_coords);
34 }