remove rotation from world tiles and instead apply it on load into atlas

This commit is contained in:
Sven Balzer
2026-05-01 19:15:03 +02:00
parent 59cb6fb6c1
commit 7cb6dbc3e6
3 changed files with 125 additions and 149 deletions
+3 -13
View File
@@ -8,7 +8,7 @@ struct VertexShaderInput {
// Per Instance
@builtin(instance_index) instance_index: u32,
@location(2) tile_info: u32,
@location(2) tile: u32,
};
struct VertexShaderOutput {
@@ -36,21 +36,11 @@ struct Per_Frame_Data {
@vertex fn main_vertex(input: VertexShaderInput) -> VertexShaderOutput {
var output: VertexShaderOutput;
let tile_type = extractBits(input.tile_info, 0, 16);
let rotation = extractBits(input.tile_info, 16, 2);
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);
output.tile = tile_type;
output.tile = input.tile;
output.pos = vec4<f32>(tile_pos + input.pos.xy, 0, 1) * view_projection_matrix;
switch (rotation) {
case 0: { output.uv = vec2<f32>( input.uv.x, input.uv.y); }
case 1: { output.uv = vec2<f32>(1.0 - input.uv.y, input.uv.x); }
case 2: { output.uv = vec2<f32>(1.0 - input.uv.x, 1.0 - input.uv.y); }
case 3: { output.uv = vec2<f32>( input.uv.y, 1.0 - input.uv.x); }
default: {}
}
output.uv = input.uv;
return output;
}