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.
1import bevy_pbr::render::forward_io::VertexOutput;
2import bevy_pbr::render::mesh_bindings::mesh;
3import 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@if(BINDLESS) {
18@group(constants::MATERIAL_BIND_GROUP) @binding(0) var<storage> materials: array<MaterialBindings>;
19@group(constants::MATERIAL_BIND_GROUP) @binding(10) var<storage> material_color: binding_array<Color>;
21@else {
22@group(constants::MATERIAL_BIND_GROUP) @binding(0) var<uniform> material_color: Color;
23@group(constants::MATERIAL_BIND_GROUP) @binding(1) var material_color_texture: texture_2d<f32>;
24@group(constants::MATERIAL_BIND_GROUP) @binding(2) var material_color_sampler: sampler;
27@fragment
28fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
29 @if(BINDLESS) {
30 let slot = mesh[in.instance_index].material_and_lightmap_bind_group_slot & 0xffffu;
31 let base_color = material_color[materials[slot].material].base_color;
32 let texture = bindless_textures_2d[materials[slot].color_texture];
33 let color_sampler = bindless_samplers_filtering[materials[slot].color_texture_sampler];
34 }
35 @else {
36 let base_color = material_color.base_color;
37 let texture = material_color_texture;
38 let color_sampler = material_color_sampler;
39 }
40 return base_color * textureSampleLevel(
41 texture,
42 color_sampler,
43 in.uv,
44 0.0
45 );
Contents