Skip to content
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

Dynamic vertex buffer layouts? #893

Closed
DiThi opened this issue Dec 9, 2017 · 3 comments
Closed

Dynamic vertex buffer layouts? #893

DiThi opened this issue Dec 9, 2017 · 3 comments

Comments

@DiThi
Copy link

DiThi commented Dec 9, 2017

In all the examples we have something like this

struct Vertex { position: [f32; 2] }
impl_vertex!(Vertex, position);

but I want to load a bunch of different meshes, some with normals, some with one or more UV layers, colors, skeletal weights, etc...

Is it possible to specify the layout at run time?

I'm sorry if there's a simple solution with a Rust feature I've missed.

@tomaka
Copy link
Member

tomaka commented Dec 10, 2017

It is doable, but not easy yet. Basically you have to implement the VertexDefinition and VertexSource traits on a struct of yours.

There is an example here: https://github.com/tomaka/vulkano-examples/blob/81f5a4eb3c5f3fcc6a194d3c41e53b2bc66f7add/gltf/gltf_system.rs#L687-L795

@Rua
Copy link
Contributor

Rua commented Nov 23, 2019

Would a partial solution be to make the Vertex trait take &self? Then it would be easy to make a custom type that returns runtime values in the member method. The various VertexDefinition types would need to take this as an argument instead of as a type.

@Rua
Copy link
Contributor

Rua commented Dec 28, 2022

There is now the VertexInputState type that gives you the same freedom as plain Vulkan.

@Rua Rua closed this as completed Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants