#import bevy_render::view::View const TEXTURED_QUAD: u32 = 0u; @group(0) @binding(0) var view: View; struct VertexOutput { @location(0) uv: vec2, @location(1) color: vec4, @location(3) @interpolate(flat) mode: u32, @builtin(position) position: vec4, }; @vertex fn vertex( @location(0) vertex_position: vec3, @location(1) vertex_uv: vec2, @location(2) vertex_color: vec4, @location(3) mode: u32, ) -> VertexOutput { var out: VertexOutput; out.uv = vertex_uv; out.position = view.view_proj * vec4(vertex_position, 1.0); out.color = vertex_color; out.mode = mode; return out; } @group(1) @binding(0) var sprite_texture: texture_2d; @group(1) @binding(1) var sprite_sampler: sampler; @fragment fn fragment(in: VertexOutput) -> @location(0) vec4 { // textureSample can only be called in unform control flow, not inside an if branch. var color = textureSample(sprite_texture, sprite_sampler, in.uv); if in.mode == TEXTURED_QUAD { color = in.color * color; } else { color = in.color; } return color; }