Skip to content

Commit

Permalink
Minimal change to support instanced rendering (bevyengine#1262)
Browse files Browse the repository at this point in the history
  • Loading branch information
alec-deason authored and rparrett committed Jan 27, 2021
1 parent b5cddb7 commit edd7d27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/bevy_render/src/shader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ pub struct ShaderLayout {
}

pub const GL_VERTEX_INDEX: &str = "gl_VertexIndex";
pub const GL_INSTANCE_INDEX: &str = "gl_InstanceIndex";
6 changes: 4 additions & 2 deletions crates/bevy_render/src/shader/shader_reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, InputStepMode,
UniformProperty, VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat,
},
shader::{ShaderLayout, GL_VERTEX_INDEX},
shader::{ShaderLayout, GL_INSTANCE_INDEX, GL_VERTEX_INDEX},
texture::{TextureComponentType, TextureViewDimension},
};
use bevy_core::AsBytes;
Expand Down Expand Up @@ -31,7 +31,9 @@ impl ShaderLayout {
// obtain attribute descriptors from reflection
let mut vertex_attribute_descriptors = Vec::new();
for input_variable in module.enumerate_input_variables(None).unwrap() {
if input_variable.name == GL_VERTEX_INDEX {
if input_variable.name == GL_VERTEX_INDEX
|| input_variable.name == GL_INSTANCE_INDEX
{
continue;
}
// reflect vertex attribute descriptor and record it
Expand Down

0 comments on commit edd7d27

Please sign in to comment.