Slow rendering of .obj files with a material specified for each face, 10k faces
Hello,
While visualizing an .obj file using f3d - a 3d viewer app using vtk, I ran into slow rendering speeds for an mesh from an .obj file that had a material specified for each individual face. I've reported this to f3d maintainers, and the issue was traced down to vtk object importer.
Rendering an .obj file with ~10k faces and ~10k usemtl
statements (1 for each face) gives 7-8 fps, while rendering the same .obj file with all usemtl
statements removed results in 500-600fps. While there are ~10k usemtl statements, there are only 4 unique materials.
The .obj file in test.obj
I acknowledge that specifying usemtl
for each face is excessive, and the .obj file could be optimized to workaround this problem.
vtk version: VTK version: 9.1.0 (build 0)
Some additional information:
I traced f3d with apitrace
, and for an .obj with usemtl
statements apitrace showed ~200,000 render calls per frame; without usemtl
: ~150 render calls per frame.
Reference to an issue in f3d app with steps to reproduce: https://github.com/f3d-app/f3d/issues/570
Thank you.