Rendering performance for millions of voxels and polyhedrons

Hello everyone! I want to render (2D and 3D) many shapes, mostly polyhedrons and partially voxels. I group them into groups (do not worry how we decide on the grouping but it can be in the order of thousands) and we need to be able to change each group’s color and opacity.
Our current flow (described into detail later) does not scale as expected e.g., a testcase with 150,000 voxels and 850,000 polyhedrons grouped in 15,385 groups renders with 0.4fps on 2D and with 0.3fps on 3D which makes the application unusable, so I am wondering how to improve it.

Current flow:

  1. Parse data (don’t worry about that)
  2. Create a list of vtkAppendFilter (with MergePointsOn()), a filter for each group of shapes
  3. Create a vtkUnstructuredGrid for each group of shapes like this:
    -If the shape is a cuboid, insert in grid as vtkVoxel
    -If the shape is polyhedron, insert in grid as vtkPolyhedron
  4. For each vtkAppendFilter create a vtkActor like this:
    1.Create vtkDataSetMapper and set input data: vtkAppendFilter->GetOutput()
    2.Create vtkActor and set the mapper
  5. Colors and opacities are changed interactively for every vtkActor

Some important notes:

  • We have limited hardware resources: no GPU
  • Shapes can be abutting or overlapping but usually only within the same group
  • We want the edges of the shapes to be visible (currently we do it with vtkActor::GetProperty().SetEdgeVisibilityOn())
  • Currently using vtk-7.1.1 (with Qt-5.15.8) with OpenGL-2.1

I have been looking for a solution in many posts here and around the web with no luck so here are some questions:

  • Do you see any flaws in our flow? Because to my knowledge, this is a standard flow
  • Given the type of geometry/shapes are the selected VTK structures the most appropriate (vtkAppendFilter, vtkUnstructuredGrid, vtkDataSetMapper, vtkActor)?
  • Last… is there a way to improve performance outside the code e.g. with some OpenGL settings? As mentioned earlier, GPU is not available and OpenGL cannot be upgraded.

Is this relevant? VTK is slow when I have a lot of actors (>10000)

This answers why you get so low frame rates. Dedicated rendering hardware was invented exactly because of this. To get acceptable frame rates for an interactive application, you have to simplify a lot your scene during user interaction (e.g. between mouse down and mouse up events). You can also try writing a bare bones vtkMapper subclass to simplify rendering enough so you get a 5-10 fps figure which is fairly decent for software rendering. Reducing resolution to a Doom-like figure (e.g. 300x200) will also improve your rates in that restrictive scenario.

Thank you a lot Paulo for your comments!
You’re right. Due to the lack of GPU acceleration we also tried Mesa with OpenSWR, but for some reason the performance was downsized for 3D rendering.

Do you know if there is a specific vtk guideline for software rendering?
Are there any examples on how to overload a vtkMapper which I can look into?

Thank you Todd!
I have seen this post and I am working on re-implementing my code with vtkGlyph3D objects. This project is my first attempt with vtk and CG in general and sometimes it is a bit difficult to understand the flow.
Do you know if it is more suitable to use vtkGlyph3DMapper of vtkProgrammableGlyphFilter? Because in some Gluph3D examples they use vtkPolyDataMapper.

Sorry. I don’t know the answer to that but I expect someone in this forum would.

Since you are moving to using vtkGlyph3D I hope you have noticed this recent topic too. Slow update when using vtkGlyph3D in Activiz 9.1

Hello,

Unfortunatelly I don’t know any VTK code practices designed for software rendering other than simplify the scene, simplify rendering (e.g. draw wireframes, disable antialiasing, etc.) and reduce resolution. Here’s my two cents.

regards,

Paulo

1 Like