Skip to content

Support gl_InstanceIndex in shaders #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2021
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
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