Skip to content

Commit 71c6a19

Browse files
authored
Minimal change to support instanced rendering (#1262)
1 parent a0475e9 commit 71c6a19

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

crates/bevy_render/src/shader/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ pub struct ShaderLayout {
2222
}
2323

2424
pub const GL_VERTEX_INDEX: &str = "gl_VertexIndex";
25+
pub const GL_INSTANCE_INDEX: &str = "gl_InstanceIndex";

crates/bevy_render/src/shader/shader_reflect.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, InputStepMode,
44
UniformProperty, VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat,
55
},
6-
shader::{ShaderLayout, GL_VERTEX_INDEX},
6+
shader::{ShaderLayout, GL_INSTANCE_INDEX, GL_VERTEX_INDEX},
77
texture::{TextureComponentType, TextureViewDimension},
88
};
99
use bevy_core::AsBytes;
@@ -31,7 +31,9 @@ impl ShaderLayout {
3131
// obtain attribute descriptors from reflection
3232
let mut vertex_attribute_descriptors = Vec::new();
3333
for input_variable in module.enumerate_input_variables(None).unwrap() {
34-
if input_variable.name == GL_VERTEX_INDEX {
34+
if input_variable.name == GL_VERTEX_INDEX
35+
|| input_variable.name == GL_INSTANCE_INDEX
36+
{
3537
continue;
3638
}
3739
// reflect vertex attribute descriptor and record it

0 commit comments

Comments
 (0)