How to create a vertex buffer within different layout? #2733
Replies: 3 comments 3 replies
-
Not entirely sure I understand your question, but I'll try: You can create vertex buffers with |
Beta Was this translation helpful? Give feedback.
-
I guess the question is how to create a vertex buffer with 2 or more layout. I'm working on https://github.com/cloudwu/efkbgfx these days, and I found using a dynamic vertex buffer with 2 or more layout is impossible :( , because if I use |
Beta Was this translation helpful? Give feedback.
-
I apologize if this is not what the original question was asking - but I am also curious as to the answer. I'm wondering if vertex streams are possible for un-interleaved data. We all know that model importing, in most game engines, does a variety of things, but also re-packs the vertex data (position, normal, tangent, color, UVs, etc.) so they are interleaved and easily digestible by a single vertex buffer object. In a GLTF exported from Blender, data for position will be packed as vector 3's (3 floats, 4 bytes per float), while the vertex color data will be packed as a vector4 (4 unsigned ints, 2 bytes per channel). While the color data is probably consuming about twice the space it needs to, I'm curious if this data could be unloaded from something like tiny-gltf directly into the GPU. In theory you might make a real-time model loader that bypasses the "model parsing" step, other than to actually load the GPU with vertex data and textures. The GLTF standard already provides the triangle indices so that part is trivial. In OpenGL terms, each |
Beta Was this translation helpful? Give feedback.
-
When call setVertexBuffer , there'a _layoutHandle parameter. I think it's possible to user a vertexbuffer with different layout
But how to create a vertex buffer with different layout?
/// Set vertex buffer for draw primitive.
///
/// @param[in] _stream Vertex stream.
/// @param[in] _handle Vertex buffer.
/// @param[in] startVertex First vertex to render.
/// @param[in] numVertices Number of vertices to render.
**/// @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. If invalid handle is
/// used, vertex layout used for creation of vertex buffer will be used.**
///
/// @attention C99 equivalent is
bgfx_set_vertex_buffer
.///
void setVertexBuffer(
uint8_t _stream
, VertexBufferHandle _handle
, uint32_t _startVertex
, uint32_t _numVertices
, VertexLayoutHandle _layoutHandle = BGFX_INVALID_HANDLE
);
Beta Was this translation helpful? Give feedback.
All reactions