diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index a0871141638a7..906d657d948b3 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -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 color: vec4; -/// @group(3) @binding(1) var color_texture: texture_2d; -/// @group(3) @binding(2) var color_sampler: sampler; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var color: vec4; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(1) var color_texture: texture_2d; +/// @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 diff --git a/crates/bevy_render/src/render_resource/bind_group.rs b/crates/bevy_render/src/render_resource/bind_group.rs index 3d808b31c4a3b..3dfd8881ce484 100644 --- a/crates/bevy_render/src/render_resource/bind_group.rs +++ b/crates/bevy_render/src/render_resource/bind_group.rs @@ -133,12 +133,12 @@ impl Deref for BindGroup { /// In WGSL shaders, the binding would look like this: /// /// ```wgsl -/// @group(3) @binding(0) var color: vec4; -/// @group(3) @binding(1) var color_texture: texture_2d; -/// @group(3) @binding(2) var color_sampler: sampler; -/// @group(3) @binding(3) var storage_buffer: array; -/// @group(3) @binding(4) var raw_buffer: array; -/// @group(3) @binding(5) var storage_texture: texture_storage_2d; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var color: vec4; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(1) var color_texture: texture_2d; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(2) var color_sampler: sampler; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(3) var storage_buffer: array; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(4) var raw_buffer: array; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(5) var storage_texture: texture_storage_2d; /// ``` /// 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. @@ -261,7 +261,7 @@ impl Deref for BindGroup { /// roughness: f32, /// }; /// -/// @group(3) @binding(0) var material: CoolMaterial; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var material: CoolMaterial; /// ``` /// /// 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 { /// declaration: /// /// ```wgsl -/// @group(3) @binding(10) var material_array: binding_array; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(10) var material_array: binding_array; /// ``` /// /// On the other hand, if you write this declaration: @@ -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 material_array: array; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(10) var material_array: array; /// ``` /// /// * Just as with the structure-level `uniform` attribute, Bevy converts the @@ -338,7 +338,7 @@ impl Deref for BindGroup { /// this in WGSL in non-bindless mode: /// /// ```wgsl -/// @group(3) @binding(0) var material: StandardMaterial; +/// @group(#{MATERIAL_BIND_GROUP}) @binding(0) var material: StandardMaterial; /// ``` /// /// * For efficiency reasons, `data` is generally preferred over `uniform` diff --git a/examples/shader_advanced/texture_binding_array.rs b/examples/shader_advanced/texture_binding_array.rs index f18d08e8d3f73..dda804390752f 100644 --- a/examples/shader_advanced/texture_binding_array.rs +++ b/examples/shader_advanced/texture_binding_array.rs @@ -164,7 +164,7 @@ impl AsBindGroup for BindlessMaterial { ( // Screen texture // - // @group(3) @binding(0) var textures: binding_array>; + // @group(#{MATERIAL_BIND_GROUP}) @binding(0) var textures: binding_array>; ( 0, texture_2d(TextureSampleType::Float { filterable: true }) @@ -172,7 +172,7 @@ impl AsBindGroup for BindlessMaterial { ), // 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: