@group(0) @binding(0) var camera: mat4x4; struct VertexInput { @location(0) position: vec2 } struct InstanceInput { @location(1) position: vec2, @location(2) size: vec2, @location(3) rotation: f32, @location(4) z_layer: u32 } struct VertexOutput { @builtin(position) clip_position: vec4 } @vertex fn vs_main(model: VertexInput, instance: InstanceInput) -> VertexOutput { var out: VertexOutput; // rotate the sprite let a = vec2(cos(instance.rotation), sin(instance.rotation)); let b = vec2(-a[1], a[0]); let rotation = mat2x2(a, b); let rotated = rotation * model.position; // scale the sprite let scaled = rotated * instance.size; // move the sprite let position2d = scaled + instance.position; // camera stuff let position4d = vec4(position2d, 0.0, 1.0); let position = camera * position4d; out.clip_position = position; return out; } @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4 { return vec4(1.0, 1.0, 1.0, 0.0); }