3 translation: vec2<f32>, 7 @location(0) position: vec2<f32>, 8 @location(1) uv: vec2<f32>, 9 @location(2) color: vec4<f32>, 13 @builtin(position) position: vec4<f32>, 14 @location(0) color: vec4<f32>, 15 @location(1) uv: vec2<f32>, 18@group(0) @binding(0) var<uniform> transform: Transform; 21@group(1) @binding(0) var image_texture: binding_array<texture_2d<f32>>; 22@group(1) @binding(1) var image_sampler: binding_array<sampler>; 23var<push_constant> offset: u32; 26@group(1) @binding(0) var image_texture: texture_2d<f32>; 27@group(1) @binding(1) var image_sampler: sampler; 31fn linear_from_gamma_rgb(srgb: vec3<f32>) -> vec3<f32> { 32 let cutoff = srgb < vec3<f32>(0.04045); 33 let lower = srgb / vec3<f32>(12.92); 34 let higher = pow((srgb + vec3<f32>(0.055)) / vec3<f32>(1.055), vec3<f32>(2.4)); 35 return select(higher, lower, cutoff); 39fn gamma_from_linear_rgb(rgb: vec3<f32>) -> vec3<f32> { 40 let cutoff = rgb < vec3<f32>(0.0031308); 41 let lower = rgb * vec3<f32>(12.92); 42 let higher = vec3<f32>(1.055) * pow(rgb, vec3<f32>(1.0 / 2.4)) - vec3<f32>(0.055); 43 return select(higher, lower, cutoff); 47fn gamma_from_linear_rgba(linear_rgba: vec4<f32>) -> vec4<f32> { 48 return vec4<f32>(gamma_from_linear_rgb(linear_rgba.rgb), linear_rgba.a); 52fn vs_main(in: VertexInput) -> VertexOutput { 53 let position = in.position * transform.scale + transform.translation; 55 return VertexOutput(vec4<f32>(position, 0.0, 1.0), in.color, in.uv); 59fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> { 61 let image_texture = image_texture[offset]; 62 let image_sampler = image_sampler[offset]; 65 let texture_color_linear = textureSample(image_texture, image_sampler, in.uv); 67 let texture_color_linear_premultiplied = vec4<f32>(texture_color_linear.rgb * texture_color_linear.a, texture_color_linear.a); 68 let texture_color_gamma_premultiplied = gamma_from_linear_rgba(texture_color_linear_premultiplied); 72 let color_gamma = texture_color_gamma_premultiplied * in.color; 74 return vec4<f32>(linear_from_gamma_rgb(color_gamma.rgb), color_gamma.a);