virocore
virocore copied to clipboard
[Feature Request] Separate triangle indices for vertices and normals in submesh
I was wondering why do the submesh triangle indices group both vertices and normals (and vertex textures). I think it would be useful if you can have separate lists for them. Suppose you have the model data in .OBJ. You can't use the indices given in the faces part because that way the normals would be wrong. You have to adjust your list of normals and vertices so that there could be a way to define with the triangle indices in submesh.
Hey @toniuyt, thanks for reaching out. I'm not sure if i fully understood your question. A combination of positional, normals and texture coordinates data are associated with each vertex, and each vertex itself is referenced via vertex indices. Thus, because this pos/norm/texcoord data is needed every vertex to perform the shading/rendering, it makes more sense to group them together. This also makes it easier to interleave the data inline in memory for performance reasons, where in openGL, group batching of data is usually preferred.
You can't use the indices given in the faces part because that way the normals would be wrong. You have to adjust your list of normals and vertices so that there could be a way to define with the triangle indices in submesh.
I'm not sure if i fully understand the above, and am a little rusty on OBJ specs. But, at least in gLTF, the above approach of grouping pos/norm/coords should also work for sub-meshes - the defined sequence of indices should refer to the right pos/norm/coord set per vertex to correctly render the face.