// Vertex shader struct VertexInput { [[location(0)]] position: vec2; [[location(1)]] offset: vec2; [[location(2)]] color: vec3; [[location(3)]] angle: f32; }; struct VertexOutput { [[builtin(position)]] clip_position: vec4; [[location(0)]] color: vec3; }; [[stage(vertex)]] fn vs_main( model: VertexInput, ) -> VertexOutput { var out: VertexOutput; out.color = model.color; out.clip_position = vec4( cos(model.angle) * model.position[0] + sin(model.angle) * model.position[1] + model.offset[0], -sin(model.angle) * model.position[0] + cos(model.angle) * model.position[1] + model.offset[1], 0.0, 1.0 ); return out; } // Fragment shader struct Data { ambient: vec4; }; [[group(0), binding(0)]] var data: Data; [[stage(fragment)]] fn fs_main(in: VertexOutput) -> [[location(0)]] vec4 { return vec4(data.ambient.rgb + in.color, data.ambient[3]); }