Created
October 28, 2020 00:29
Star
You must be signed in to star a gist
vulkano vertex attributes
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
So my vertex shader inputs look like this, pretty basic: | |
layout(location = 0) in vec2 v_pos; | |
layout(location = 1) in vec2 v_tex; | |
layout(location = 2) in vec4 v_col; | |
layout(location = 3) in vec4 v_opt; | |
And after following the examples, I can implement the `Vertex` trait on my struct using this macro: | |
#[derive(Default, Debug, Clone)] | |
struct Vertex { | |
v_pos: [f32; 2], | |
v_tex: [f32; 2], | |
v_col: [f32; 4], | |
v_opt: [f32; 4], | |
} | |
vulkano::impl_vertex!(Vertex, v_pos, v_tex, v_col, v_opt); | |
All is good. But in OpenGL, I never use 4 32-bit floats for colors, I just use 4-byte colors and tell `glVertexAttribPointer` to normalize them. So I want my vertices to look like this... | |
#[derive(Default, Debug, Clone)] | |
struct Vertex { | |
v_pos: [f32; 2], | |
v_tex: [f32; 2], | |
v_col: [u8; 4], | |
v_opt: [u8; 4], | |
} | |
But when I actually create my pipeline later on... | |
GraphicsPipeline::start() | |
.vertex_input_single_buffer::<Vertex>() | |
... | |
I get this type mismatch error. | |
IncompatibleVertexDefinition(FormatMismatch { attribute: "v_col", shader: (R32G32B32A32Sfloat, 1), definition: (U8, 4) }) | |
The error is very clear. But how do I tell Vulkano that `v_col` and `v_opt` should be R8G8B8A8Unorm formatted? I didn't see anywhere in the example code where I could specify the attribute format, only its offset and name. | |
thanks! |
No i did not, sorry. i’ve moved away from vulkano unfortunately.
Thanks for the reply :) Out of curiosity, what did you move to?
i'm using Glutin and OpenGL right now. i've set up my system so that i can swap out graphics systems, so i hope to get proper DX/Vulkan renderers at some point, but it's just too complicated for me at the moment. hopefully at some point we'll get a very usable library that wraps these things (if i was talented i would write it myself).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey :) Did you figure this out? I'm having the same problem.