jkuhlmann / cgltf

:diamond_shape_with_a_dot_inside: Single-file glTF 2.0 loader and writer written in C99
MIT License
1.42k stars 135 forks source link

native app EXT_meshopt_compression support #241

Closed rarest closed 8 months ago

rarest commented 8 months ago
  1. I use gltfpack to encode the GLB model with command "gltfpack -i qintaidasha.glb -o qintaidashacoptmesh.glb -cc"
  2. when decode with cgltf, the format of the mesh's vertex and texture data which finded in meshopt_compression is u16
  3. how can i render the mesh in opengles3 or metal api? thanks!
zeux commented 8 months ago

Assuming you're decompressing the buffer views per sample in the description here https://github.com/jkuhlmann/cgltf/pull/129 you just need to pass the data to the GPU as uint16, for example when using GLES3 you'd use glVertexAttribPointer(index, 3, GL_UNSIGNED_SHORT, false, 8, ptr); for position (make sure to get stride from the attributes though, it's the same process really as any other glTF file - the only difference is the type of components is not GL_FLOAT). This is not specific to EXT_meshopt_compression and is required for any use of KHR_mesh_quantization.

rarest commented 8 months ago

I understand now, I'll give it a try. If I have any questions, I'll ask you for further guidance. Thank you for your patient response, it's a great project! 👍🏻👍🏻