get rid of tile_infos buffer for world shader and instead just use the vertex uvs
This commit is contained in:
+6
-45
@@ -3,11 +3,12 @@ struct VertexShaderInput {
|
||||
@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(1) tile_info: u32,
|
||||
@location(2) tile_info: u32,
|
||||
};
|
||||
|
||||
struct VertexShaderOutput {
|
||||
@@ -32,8 +33,6 @@ struct Per_Frame_Data {
|
||||
@group(0) @binding(0) var<uniform> view_projection_matrix: mat4x4<f32>;
|
||||
@group(0) @binding(1) var<uniform> per_frame: Per_Frame_Data;
|
||||
|
||||
@group(1) @binding(3) var<storage, read> tile_infos: array<vec4<f32>>;
|
||||
|
||||
@vertex fn main_vertex(input: VertexShaderInput) -> VertexShaderOutput {
|
||||
var output: VertexShaderOutput;
|
||||
|
||||
@@ -45,49 +44,11 @@ struct Per_Frame_Data {
|
||||
output.tile = tile_type;
|
||||
output.pos = vec4<f32>(tile_pos + input.pos.xy, 0, 1) * view_projection_matrix;
|
||||
|
||||
let uv_min_max = tile_infos[tile_type];
|
||||
|
||||
switch (rotation) {
|
||||
case 0: {
|
||||
switch (input.vertex_index) {
|
||||
case 0: { output.uv = uv_min_max.xy; }
|
||||
case 1: { output.uv = uv_min_max.xw; }
|
||||
case 2: { output.uv = uv_min_max.zw; }
|
||||
case 3: { output.uv = uv_min_max.zy; }
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
|
||||
case 1: {
|
||||
switch (input.vertex_index) {
|
||||
case 0: { output.uv = uv_min_max.zy; }
|
||||
case 1: { output.uv = uv_min_max.xy; }
|
||||
case 2: { output.uv = uv_min_max.xw; }
|
||||
case 3: { output.uv = uv_min_max.zw; }
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
|
||||
case 2: {
|
||||
switch (input.vertex_index) {
|
||||
case 0: { output.uv = uv_min_max.zw; }
|
||||
case 1: { output.uv = uv_min_max.zy; }
|
||||
case 2: { output.uv = uv_min_max.xy; }
|
||||
case 3: { output.uv = uv_min_max.xw; }
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
|
||||
case 3: {
|
||||
switch (input.vertex_index) {
|
||||
case 0: { output.uv = uv_min_max.xw; }
|
||||
case 1: { output.uv = uv_min_max.zw; }
|
||||
case 2: { output.uv = uv_min_max.zy; }
|
||||
case 3: { output.uv = uv_min_max.xy; }
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
|
||||
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: {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user