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
2#import bevy_pbr::mesh_bindings::mesh
3#import bevy_render::bindless::{bindless_samplers_filtering, bindless_textures_2d}
5struct Color {
6 base_color: vec4<f32>,
7}
9// This structure is a mapping from bindless index to the index in the
10// appropriate slab
11struct MaterialBindings {
12 material: u32, // 0
13 color_texture: u32, // 1
14 color_texture_sampler: u32, // 2
17#ifdef BINDLESS
18@group(2) @binding(0) var<storage> materials: array<MaterialBindings>;
19@group(2) @binding(10) var<storage> material_color: binding_array<Color>;
20#else // BINDLESS
21@group(2) @binding(0) var<uniform> material_color: Color;
22@group(2) @binding(1) var material_color_texture: texture_2d<f32>;
23@group(2) @binding(2) var material_color_sampler: sampler;
24#endif // BINDLESS
26@fragment
27fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
28#ifdef BINDLESS
29 let slot = mesh[in.instance_index].material_and_lightmap_bind_group_slot & 0xffffu;
30 let base_color = material_color[materials[slot].material].base_color;
31#else // BINDLESS
32 let base_color = material_color.base_color;
33#endif // BINDLESS
35 return base_color * textureSampleLevel(
36#ifdef BINDLESS
37 bindless_textures_2d[materials[slot].color_texture],
38 bindless_samplers_filtering[materials[slot].color_texture_sampler],
39#else // BINDLESS
40 material_color_texture,
41 material_color_sampler,
42#endif // BINDLESS
43 in.uv,
44 0.0
45 );
Contents