struct Uniforms { camera: vec2f, zooms: vec2f } @group(0) @binding(0) var uniforms : Uniforms; struct VertexOutput { @location(0) tex_coords: vec2f, @location(1) color: vec4f, @builtin(position) pos: vec4f } @vertex fn vs_main( @location(0) pos: vec2f, @location(1) tex_coords: vec2f, @location(2) effect: u32 ) -> VertexOutput { var out: VertexOutput; return out; } @group(1) @binding(0) var t_diffuse: texture_2d; @group(1) @binding(1) var s_diffuse: sampler; @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4f { var tex_col = textureSample(t_diffuse, s_diffuse, in.tex_coords); var color = vec4f((tex_col.rgb * tex_col.a) + (in.color.rgb * in.color.a), tex_col.a + in.color.a); if effect & 0100u != 0u { color = vec4f(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a); } switch effect { case 1u, 3u: { var v = (color.r*0.299) + (color.g*0.587) + (color.b*0.114); color = vec4f(v, v, v, color.a); } case 0u, 2u: { color = color; } default: {} } switch effect { case 0u, 1u: { pos = vec4f(pos, 0, 1); } case 2u, 3u: { pos = vec4f((pos - uniforms.camera) * uniforms.zooms, 0, 1); } default: {} } return color; }