Vulkano: Dynamic vertex buffer layouts?

Created on 9 Dec 2017  路  2Comments  路  Source: vulkano-rs/vulkano

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.

documentation

Most helpful comment

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

All 2 comments

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

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.

Was this page helpful?
0 / 5 - 0 ratings