@group(0) @binding(2) var dimensions: vec2; struct VertexInput { @location(0) position: vec3, } struct InstanceInput { @location(1) color: vec4, @location(2) model_matrix_0: vec4, @location(3) model_matrix_1: vec4, @location(4) model_matrix_2: vec4, @location(5) model_matrix_3: vec4, }; struct VertexOutput { @builtin(position) position: vec4, @location(0) color: vec4, } @vertex fn vs_main( model: VertexInput, instance: InstanceInput, ) -> VertexOutput { var out: VertexOutput; let model_matrix = mat4x4( instance.model_matrix_0, instance.model_matrix_1, instance.model_matrix_2, instance.model_matrix_3, ); out.position = model_matrix * vec4(model.position, 1.0); out.position.z = 0.999; // To keep the aspect ratio let dims = vec2(dimensions); if (dimensions.x < dimensions.y) { out.position.x = out.position.x * dims.y / dims.x; } else { out.position.y = out.position.y * dims.x / dims.y; } out.color = instance.color; return out; } @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4 { return in.color; }