Last active
June 11, 2020 11:27
-
-
Save hasenbanck/e288cbf0ee246ab30d938ae877564712 to your computer and use it in GitHub Desktop.
Instanced rendering with vertex arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Stage { flag: VERTEX, error: Input { location: 4, error: WrongType } }', C:\Users\Username\.cargo\git\checkouts\wgpu-rs-40ea39809c03c5d8\7b866b1\src\backend\direct.rs:460:9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
vertex_state: wgpu::VertexStateDescriptor { | |
index_format: wgpu::IndexFormat::Uint32, | |
vertex_buffers: &[ | |
wgpu::VertexBufferDescriptor { | |
stride: 11 * 4, | |
step_mode: wgpu::InputStepMode::Vertex, | |
// 0: vec3 position | |
// 1: vec3 normal | |
// 2: vec3 tangent | |
// 3: vec2 texture coordinates | |
attributes: &vertex_attr_array![0 => Float3, 1 => Float3, 2 => Float3, 3 => Float2], | |
}, | |
wgpu::VertexBufferDescriptor { | |
stride: 16 * 4, | |
step_mode: wgpu::InputStepMode::Instance, | |
// 4: mat4 MVP matrix | |
attributes: &vertex_attr_array![4 => Float4, 5 => Float4, 6 => Float4, 7 => Float4], | |
} | |
], | |
}, | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 450 | |
layout(location=0) in vec3 a_position; | |
layout(location=1) in vec3 a_normal; | |
layout(location=2) in vec3 a_tangent; | |
layout(location=3) in vec2 a_tex_coord; | |
layout(location=4) in mat4 a_mvp; | |
layout(location=0) out vec2 v_tex_coord; | |
layout(set=0, binding=0) | |
uniform Uniforms { | |
float global_light_intensity; | |
}; | |
void main() { | |
v_tex_coord = a_tex_coord; | |
gl_Position = a_mvp * vec4(a_position, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment