vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

[QUESTION] How to properly access GLTF mesh data for GL use #189

Closed marv7000 closed 11 months ago

marv7000 commented 11 months ago

I feel like an idiot trying to get sequential vertex data (for VAOs) out of a MeshPrimitive and write it to a Stream, but I can only get them grouped by Accessor with MeshPrimitive.GetVertices(string). Is there a function I missed or is there no good solution for this?

vpenades commented 11 months ago

As per glTF specification, the right way to go is this:

you simply upload the buffers to the GPU as is (LogicalBuffers marked for GPU usage in the library), then, BufferViews let you know the ranges where vertices and indices begin and end, and finally, primitives let you know which bufferviews to use for rendering.

In other words, the Buffers, BufferViews and Primitives are designed so you don't do any kind of transformation on the data, you just upload the buffers to the GPU as is and then use the views and the primitives to select the appropiate ranges of the buffers for rendering.

This link might be useful: https://toji.github.io/webgpu-gltf-case-study/

marv7000 commented 11 months ago

Thanks, marking this as closed.