Skip to content

Commit aa8a777

Browse files
authored
Update docs to use MATERIAL_BIND_GROUP (#20458)
# Objective - Make the docs consistent with the shaders ## Solution - Fix them ## Testing - its docs
1 parent 6eb4d62 commit aa8a777

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

crates/bevy_pbr/src/material.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ pub const MATERIAL_BIND_GROUP_INDEX: usize = 3;
124124
/// In WGSL shaders, the material's binding would look like this:
125125
///
126126
/// ```wgsl
127-
/// @group(3) @binding(0) var<uniform> color: vec4<f32>;
128-
/// @group(3) @binding(1) var color_texture: texture_2d<f32>;
129-
/// @group(3) @binding(2) var color_sampler: sampler;
127+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var<uniform> color: vec4<f32>;
128+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(1) var color_texture: texture_2d<f32>;
129+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(2) var color_sampler: sampler;
130130
/// ```
131131
pub trait Material: Asset + AsBindGroup + Clone + Sized {
132132
/// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the default mesh vertex shader

crates/bevy_render/src/render_resource/bind_group.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ impl Deref for BindGroup {
133133
/// In WGSL shaders, the binding would look like this:
134134
///
135135
/// ```wgsl
136-
/// @group(3) @binding(0) var<uniform> color: vec4<f32>;
137-
/// @group(3) @binding(1) var color_texture: texture_2d<f32>;
138-
/// @group(3) @binding(2) var color_sampler: sampler;
139-
/// @group(3) @binding(3) var<storage> storage_buffer: array<f32>;
140-
/// @group(3) @binding(4) var<storage> raw_buffer: array<f32>;
141-
/// @group(3) @binding(5) var storage_texture: texture_storage_2d<rgba8unorm, read_write>;
136+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var<uniform> color: vec4<f32>;
137+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(1) var color_texture: texture_2d<f32>;
138+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(2) var color_sampler: sampler;
139+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(3) var<storage> storage_buffer: array<f32>;
140+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(4) var<storage> raw_buffer: array<f32>;
141+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(5) var storage_texture: texture_storage_2d<rgba8unorm, read_write>;
142142
/// ```
143143
/// Note that the "group" index is determined by the usage context. It is not defined in [`AsBindGroup`]. For example, in Bevy material bind groups
144144
/// are generally bound to group 2.
@@ -261,7 +261,7 @@ impl Deref for BindGroup {
261261
/// roughness: f32,
262262
/// };
263263
///
264-
/// @group(3) @binding(0) var<uniform> material: CoolMaterial;
264+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var<uniform> material: CoolMaterial;
265265
/// ```
266266
///
267267
/// Some less common scenarios will require "struct-level" attributes. These are the currently supported struct-level attributes:
@@ -312,7 +312,7 @@ impl Deref for BindGroup {
312312
/// declaration:
313313
///
314314
/// ```wgsl
315-
/// @group(3) @binding(10) var<storage> material_array: binding_array<StandardMaterial>;
315+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(10) var<storage> material_array: binding_array<StandardMaterial>;
316316
/// ```
317317
///
318318
/// On the other hand, if you write this declaration:
@@ -325,7 +325,7 @@ impl Deref for BindGroup {
325325
/// Then Bevy produces a binding that matches this WGSL declaration instead:
326326
///
327327
/// ```wgsl
328-
/// @group(3) @binding(10) var<storage> material_array: array<StandardMaterial>;
328+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(10) var<storage> material_array: array<StandardMaterial>;
329329
/// ```
330330
///
331331
/// * Just as with the structure-level `uniform` attribute, Bevy converts the
@@ -338,7 +338,7 @@ impl Deref for BindGroup {
338338
/// this in WGSL in non-bindless mode:
339339
///
340340
/// ```wgsl
341-
/// @group(3) @binding(0) var<uniform> material: StandardMaterial;
341+
/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var<uniform> material: StandardMaterial;
342342
/// ```
343343
///
344344
/// * For efficiency reasons, `data` is generally preferred over `uniform`

examples/shader_advanced/texture_binding_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,15 @@ impl AsBindGroup for BindlessMaterial {
164164
(
165165
// Screen texture
166166
//
167-
// @group(3) @binding(0) var textures: binding_array<texture_2d<f32>>;
167+
// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var textures: binding_array<texture_2d<f32>>;
168168
(
169169
0,
170170
texture_2d(TextureSampleType::Float { filterable: true })
171171
.count(NonZero::<u32>::new(MAX_TEXTURE_COUNT as u32).unwrap()),
172172
),
173173
// Sampler
174174
//
175-
// @group(3) @binding(1) var nearest_sampler: sampler;
175+
// @group(#{MATERIAL_BIND_GROUP}) @binding(1) var nearest_sampler: sampler;
176176
//
177177
// Note: as with textures, multiple samplers can also be bound
178178
// onto one binding slot:

0 commit comments

Comments
 (0)