Hi all.
In my Java-based, VTK-based application, I am working on the implementation of volume rendering functionalities. I am working with the latest VTK 8.2.
All is working pretty well at the moment: I can generate and view my volume correctly, and I can interact with the volume and with the view in a satisfactory way through the standard interactor of my vtkCanvas-derived GUI panel.
I have implemented a “reset view” function in my application, which resets the “default” camera view through a code looking like this:
=====
vtkRenderer existingCanvasRenderer = GetRenderer();
vtkCamera activeCamera = existingCanvasRenderer.GetActiveCamera();
double[] volCenter = volume.GetCenter();
activeCamera.SetFocalPoint (volCenter[0], volCenter[1], volCenter[2]);
activeCamera.SetPosition (volCenter[0], volCenter[1] - 850, volCenter[2]);
activeCamera.SetViewUp (0, 0, 1);
activeCamera.Azimuth(30.0);
activeCamera.Elevation(30.0);
activeCamera.ComputeViewPlaneNormal();
activeCamera.UpdateViewport(existingCanvasRenderer);
repaint();
=====
However, “sometimes”, immediately after this view reset my scene appears a bit too dark, or at least with an incorrect lighting.
Then, the first time I interact again with the view through the mouse, for instance by dragging the scene and thus applying the slightest rotation to the camera, lighting is restored to normal state.
Here is how the view appeared in a specific case after view reset:
And here is how it is restored to normal lighting after the slightest mouse interaction with the view:
You can notice a significant difference between the 2 renderings, with the second being the “correct” one.
Should I make some additional calls in my “view reset” code in order to force an update of the lighting of my scene, following to reset of my camera position and orientation? Can you suggest why lighting doesn’t seem correct immediately after my “view reset” operation, at least in some cases?
Thanks in advance for your comments.
Best regards,
Marco Sambin