remove vertex and index buffer from world shader

This commit is contained in:
Sven Balzer
2026-05-01 19:27:57 +02:00
parent 7cb6dbc3e6
commit fa9190b0e5
2 changed files with 15 additions and 34 deletions
+10 -6
View File
@@ -2,13 +2,10 @@ struct VertexShaderInput {
// Per Vertex
@builtin(vertex_index) vertex_index: u32,
@location(0) pos: vec3<f32>,
@location(1) uv: vec2<f32>,
// Per Instance
@builtin(instance_index) instance_index: u32,
@location(2) tile: u32,
@location(0) tile: u32,
};
struct VertexShaderOutput {
@@ -37,10 +34,17 @@ struct Per_Frame_Data {
var output: VertexShaderOutput;
let tile_pos = vec2<f32>(f32(input.instance_index % per_frame.map_width), f32(input.instance_index / per_frame.map_width)) - vec2<f32>(0.5, 0.5);
switch (input.vertex_index) {
case 0: { output.pos = vec4<f32>(tile_pos + vec2<f32>(-0.5, 0.5), 0, 1) * view_projection_matrix; output.uv = vec2<f32>(0, 0); }
case 1: { output.pos = vec4<f32>(tile_pos + vec2<f32>(-0.5, -0.5), 0, 1) * view_projection_matrix; output.uv = vec2<f32>(0, 1); }
case 2: { output.pos = vec4<f32>(tile_pos + vec2<f32>( 0.5, -0.5), 0, 1) * view_projection_matrix; output.uv = vec2<f32>(1, 1); }
case 3: { output.pos = vec4<f32>(tile_pos + vec2<f32>(-0.5, 0.5), 0, 1) * view_projection_matrix; output.uv = vec2<f32>(0, 0); }
case 4: { output.pos = vec4<f32>(tile_pos + vec2<f32>( 0.5, -0.5), 0, 1) * view_projection_matrix; output.uv = vec2<f32>(1, 1); }
case 5: { output.pos = vec4<f32>(tile_pos + vec2<f32>( 0.5, 0.5), 0, 1) * view_projection_matrix; output.uv = vec2<f32>(1, 0); }
default: {}
}
output.tile = input.tile;
output.pos = vec4<f32>(tile_pos + input.pos.xy, 0, 1) * view_projection_matrix;
output.uv = input.uv;
return output;
}