mirror of
https://github.com/bevyengine/bevy.git
synced 2026-07-01 08:12:51 -04:00
e6ec2c181d
Use a shader def for the material bind group index to make it easier for when we want to switch back to group 2 in the future without breaking everyone again. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: atlv <email@atlasdostal.com> Co-authored-by: atlas dostal <rodol@rivalrebels.com>
18 lines
672 B
WebGPU Shading Language
18 lines
672 B
WebGPU Shading Language
#import bevy_pbr::forward_io::VertexOutput
|
|
|
|
@group(#{MATERIAL_BIND_GROUP}) @binding(0) var textures: binding_array<texture_2d<f32>>;
|
|
@group(#{MATERIAL_BIND_GROUP}) @binding(1) var nearest_sampler: sampler;
|
|
// We can also have array of samplers
|
|
// var samplers: binding_array<sampler>;
|
|
|
|
@fragment
|
|
fn fragment(
|
|
mesh: VertexOutput,
|
|
) -> @location(0) vec4<f32> {
|
|
// Select the texture to sample from using non-uniform uv coordinates
|
|
let coords = clamp(vec2<u32>(mesh.uv * 4.0), vec2<u32>(0u), vec2<u32>(3u));
|
|
let index = coords.y * 4u + coords.x;
|
|
let inner_uv = fract(mesh.uv * 4.0);
|
|
return textureSample(textures[index], nearest_sampler, inner_uv);
|
|
}
|