A material that uses bindless textures.
use *;
use ;
const SHADER_ASSET_PATH: &str = "shaders/bindless_material.wgsl";
// `#[bindless(limit(4))]` indicates that we want Bevy to group materials into
// bind groups of at most 4 materials each.
// Note that we use the structure-level `#[uniform]` attribute to supply
// ordinary data to the shader.
// This buffer will be presented to the shader as `@binding(10)`.
// The entry point.
// Creates a simple scene.
#import bevy_pbr::forward_io::VertexOutput
#import bevy_pbr::mesh_bindings::mesh
#import bevy_render::bindless::{bindless_samplers_filtering, bindless_textures_2d}
struct Color {
base_color: vec4<f32>,
}
// This structure is a mapping from bindless index to the index in the
// appropriate slab
struct MaterialBindings {
material: u32, // 0
color_texture: u32, // 1
color_texture_sampler: u32, // 2
}
#ifdef BINDLESS
(2) (0) var<storage> materials: array<MaterialBindings>;
(2) (10) var<storage> material_color: binding_array<Color>;
#else // BINDLESS
(2) (0) var<uniform> material_color: Color;
(2) (1) var material_color_texture: texture_2d<f32>;
(2) (2) var material_color_sampler: sampler;
#endif // BINDLESS
fn -> (0) vec4<f32> {
#ifdef BINDLESS
let slot = mesh[in.instance_index].material_and_lightmap_bind_group_slot & 0xffffu;
let base_color = material_color[materials[slot].material].base_color;
#else // BINDLESS
let base_color = material_color.base_color;
#endif // BINDLESS
return base_color * ;
}