Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ pub const MATERIAL_BIND_GROUP_INDEX: usize = 3;
/// In WGSL shaders, the material's binding would look like this:
///
/// ```wgsl
/// @group(3) @binding(0) var<uniform> color: vec4<f32>;
/// @group(3) @binding(1) var color_texture: texture_2d<f32>;
/// @group(3) @binding(2) var color_sampler: sampler;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var<uniform> color: vec4<f32>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(1) var color_texture: texture_2d<f32>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(2) var color_sampler: sampler;
/// ```
pub trait Material: Asset + AsBindGroup + Clone + Sized {
/// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the default mesh vertex shader
Expand Down
20 changes: 10 additions & 10 deletions crates/bevy_render/src/render_resource/bind_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ impl Deref for BindGroup {
/// In WGSL shaders, the binding would look like this:
///
/// ```wgsl
/// @group(3) @binding(0) var<uniform> color: vec4<f32>;
/// @group(3) @binding(1) var color_texture: texture_2d<f32>;
/// @group(3) @binding(2) var color_sampler: sampler;
/// @group(3) @binding(3) var<storage> storage_buffer: array<f32>;
/// @group(3) @binding(4) var<storage> raw_buffer: array<f32>;
/// @group(3) @binding(5) var storage_texture: texture_storage_2d<rgba8unorm, read_write>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var<uniform> color: vec4<f32>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(1) var color_texture: texture_2d<f32>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(2) var color_sampler: sampler;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(3) var<storage> storage_buffer: array<f32>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(4) var<storage> raw_buffer: array<f32>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(5) var storage_texture: texture_storage_2d<rgba8unorm, read_write>;
/// ```
/// Note that the "group" index is determined by the usage context. It is not defined in [`AsBindGroup`]. For example, in Bevy material bind groups
/// are generally bound to group 2.
Expand Down Expand Up @@ -261,7 +261,7 @@ impl Deref for BindGroup {
/// roughness: f32,
/// };
///
/// @group(3) @binding(0) var<uniform> material: CoolMaterial;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var<uniform> material: CoolMaterial;
/// ```
///
/// Some less common scenarios will require "struct-level" attributes. These are the currently supported struct-level attributes:
Expand Down Expand Up @@ -312,7 +312,7 @@ impl Deref for BindGroup {
/// declaration:
///
/// ```wgsl
/// @group(3) @binding(10) var<storage> material_array: binding_array<StandardMaterial>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(10) var<storage> material_array: binding_array<StandardMaterial>;
/// ```
///
/// On the other hand, if you write this declaration:
Expand All @@ -325,7 +325,7 @@ impl Deref for BindGroup {
/// Then Bevy produces a binding that matches this WGSL declaration instead:
///
/// ```wgsl
/// @group(3) @binding(10) var<storage> material_array: array<StandardMaterial>;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(10) var<storage> material_array: array<StandardMaterial>;
/// ```
///
/// * Just as with the structure-level `uniform` attribute, Bevy converts the
Expand All @@ -338,7 +338,7 @@ impl Deref for BindGroup {
/// this in WGSL in non-bindless mode:
///
/// ```wgsl
/// @group(3) @binding(0) var<uniform> material: StandardMaterial;
/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var<uniform> material: StandardMaterial;
/// ```
///
/// * For efficiency reasons, `data` is generally preferred over `uniform`
Expand Down
4 changes: 2 additions & 2 deletions examples/shader_advanced/texture_binding_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ impl AsBindGroup for BindlessMaterial {
(
// Screen texture
//
// @group(3) @binding(0) var textures: binding_array<texture_2d<f32>>;
// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var textures: binding_array<texture_2d<f32>>;
(
0,
texture_2d(TextureSampleType::Float { filterable: true })
.count(NonZero::<u32>::new(MAX_TEXTURE_COUNT as u32).unwrap()),
),
// Sampler
//
// @group(3) @binding(1) var nearest_sampler: sampler;
// @group(#{MATERIAL_BIND_GROUP}) @binding(1) var nearest_sampler: sampler;
//
// Note: as with textures, multiple samplers can also be bound
// onto one binding slot:
Expand Down
Loading