Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#import bevy_pbr::forward_io::VertexOutput
3@group(#{MATERIAL_BIND_GROUP}) @binding(0) var textures: binding_array<texture_2d<f32>>;
4@group(#{MATERIAL_BIND_GROUP}) @binding(1) var nearest_sampler: sampler;
5// We can also have array of samplers
6// var samplers: binding_array<sampler>;
8@fragment
9fn fragment(
10 mesh: VertexOutput,
11) -> @location(0) vec4<f32> {
12 // Select the texture to sample from using non-uniform uv coordinates
13 let coords = clamp(vec2<u32>(mesh.uv * 4.0), vec2<u32>(0u), vec2<u32>(3u));
14 let index = coords.y * 4u + coords.x;
15 let inner_uv = fract(mesh.uv * 4.0);
16 return textureSample(textures[index], nearest_sampler, inner_uv);
Contents