From 45282d3a54cc50306383c41e4c7e3d982cac69d1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 6 Jan 2025 22:36:03 +0100 Subject: mesh not visible --- client/src/shader.wgsl | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'client/src/shader.wgsl') diff --git a/client/src/shader.wgsl b/client/src/shader.wgsl index 41c21d9..68bd93d 100644 --- a/client/src/shader.wgsl +++ b/client/src/shader.wgsl @@ -1,11 +1,30 @@ -@vertex -fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4 { - let x = f32(i32(in_vertex_index) % 2); - let y = f32(i32(in_vertex_index & 1u) * 2 - 1); - return vec4(x, y, 0.0, 1.0); + +struct VertexIn { + @location(0) x: f32, + @location(1) y: f32, + @location(2) z: f32, + @location(3) nx: f32, + @location(4) ny: f32, + @location(5) nz: f32, + @location(6) u: f32, + @location(7) v: f32, +} +struct VertexOut { + @builtin(position) clip: vec4, + @location(0) normal: vec3, + @location(1) uv: vec2, } +@vertex +fn vs_main(vi: VertexIn) -> VertexOut { + let vo = VertexOut( + vec4(vi.x * 0.1, vi.y * 0.1, 0., 1.), + vec3(vi.nx, vi.ny, vi.nz), + vec2(vi.u, vi.v), + ); + return vo; +} @fragment -fn fs_main() -> @location(0) vec4 { - return vec4(1.0, 0.0, 0.0, 1.0); +fn fs_main(vo: VertexOut) -> @location(0) vec4 { + return vec4(vo.normal, 1.0); } -- cgit v1.2.3-70-g09d2