After adjusting the position of the vtkCamera, I need to call vtkRenderWindow::Render() to refresh the view. However, in my application scenario (1 million nodes in Debug mode), each call to Render() takes about 4 seconds. The object I drew remained unchanged; I merely adjusted the camera perspective.
vtkSmartPointer<vtkCamera> camera = renderer->GetActiveCamera();
camera->SetPosition(newX, newY, newZ);
*// camera->SetFocalPoint(...); // or other camera parameter adjustments*
renderWindow->Render(); *// This call takes about 4 seconds*
My question:
When only the camera parameters are adjusted without changing the scene content, is it necessary to call Render()? Is there a more efficient way to refresh?
Is it normal for each Render() call to take 4 seconds in a scenario with 1 million nodes? Or does it indicate that there is a problem with my rendering pipeline?
Yes, any changes made to the camera requires a re-rendering;
It depends on far too many factors. I had wireframe scenes rendering in thousand-some FPS, on the other hand, I had a scene once that took hours to photorealistically render using a ray-casting algorithm. Both normal cases. But if your scene requires 4s to render, you may need to switch to a simplified data and/or rendering pipeline during interaction and switch back after user releases the mouse.
VTK uses timestamps to check whether to reload the geometry onto the GPU. So if the timestamp on the points array doesn’t change, calling Render() after moving the camera should be quick, since the buffers are re-used.
A million nodes isn’t much. Slow rendering in VTK is more often caused by the use of a large number of actors (even 1000 actors would be considered excessive) rather than the use of large datasets.
Is there any way to check if the timestamp has changed? What I can confirm is that only one Actor was added to carry the node object, and the adjustment to the camera was only to change the position and focus. However, the time consumed by calling render in the end is basically the same as that of initially adding the actor
Are there any relevant filters or examples for the generation of this simplified model? Or add examples of multiple rendering pipelines. This is indeed a good idea
Call GetMTime() on the vtkPoints object for your dataset, e.g. data->GetPoints()->GetMTime() if your dataset is vtkPolyData or vtkUnstructuredGrid. Call it after the first Render(), and call it again after the next Render(). The returned value should not change. You can do the same check with any scalar arrays that are in your dataset.