Stereo mode in VTK, effect is abnormal

Hello, when I was developing the program of the stereo naked-eye 3D screen, I found that when using vtkOpenGLGPUVolumeRayCastMapper for voxel rendering, the voxel rendering effect was incorrect. There were some distorted errors. Has anyone encountered a similar problem? How was it solved?vkt version:9.3.1
The following is a part of my code for enabling the stereo mode in vtkRenderWindow.

vtkVolume* volume = vtkVolume::New();
volume = load_dicom_data(argc, argv);

vtkNew ren1;
ren1->AddViewProp(volume);

vtkNew renWin;
renWin->AddRenderer(ren1);
renWin->SetSize(1024, 768);
renWin->SetWindowName(“Tutorial_Step5”);
renWin->StereoRenderOn();
renWin->StereoCapableWindowOn();
renWin->SetStereoTypeToSplitViewportHorizontal();
renWin->SetStereoRender(true);

:smiley:
By the way, if vtkFixedPointVolumeRayCastMapper is used, although the frame rate is not very high, there is no distortion problem. Could any expert help answer this?
but show this warning:vtkWin32OpenGLRenderWindow (000001E01B968FC0): Adjusting stereo mode on a window that does not support stereo type CrystalEyes is not possible.

Add more:
I made the camera an off-axis type by setting the eyeangle.
like this:

vtkCamera* cam = ren1->GetActiveCamera();
cam->SetEyeAngle(30);

Hi Hakukou,

I haven’t worked with the SplitViewportHorizontal stereo mode much, but there’s at least one test in the repository that shows how to use it [1].

Also, to make the camera off-axis, you need to invoke the following method on the camera, as in the test:

camera->SetUseOffAxisProjection(1);

Also, off-axis projection requires knowing the physical coordinates of the screen, also demonstrated in the test:

camera->SetScreenBottomLeft(…);
camera->SetScreenBottomRight(…);

camera->SetScreenTopRight(…);

And a couple more things: to adjust the stereo image separation in off-axis mode, you should use camera->SetEyeSeparation() instead of camera->SetEyeAngle(). Also, off-axis mode ignores the Position, FocalPoint, and ViewUp properties of the camera, and instead uses EyePosition / EyeTransformMatrix as the view point.

There are a couple other tests that exercise off-axis projection as well: [2], [3]

If you can share a more complete code sample and the data file used to make the images in your original post, that could help us to better diagnose what could be going wrong.

Cheers,
Scott

[1] Rendering/Core/Testing/Cxx/TestSplitViewportStereoHorizontal.cxx
[2] Rendering/Core/Testing/Cxx/TestOffAxisStereo.cxx
[3] Rendering/Core/Testing/Cxx/TestStereoEyeSeparation.cxx

Thank you very much for your help. I called and tested it according to the way you provided to implement off-axis addition. I found that the display based on Poly was relatively correct. However, when I used dicom data to display voxel rendering, I couldn’t see the correct effect. The phenomenon was that only a very local picture was seen in the camera. And at this time, the vtkRenderWindowInteractor seemed not to work. I couldn’t zoom out the camera through the mouse to see the full picture. How should I control the camera in this case? Do I need to write an Interactor based on controlling the eyeposition by myself? Of course, it would be great if there were an example of voxel rendering based on Dicom and the effect of the off-axis camera was achieved. Because our naked-eye 3D product has an eye tracking process that can obtain the coordinates of the centers of the left and right eyes. I want to determine the degree of absolute shear through this coordinate. At the same time, I also hope that the mouse operation can work at the same time. That is, the binocular camera and the focal plane are regarded as a whole. The matrix of their parent node is controlled by the mouse. I don’t know if it can be achieved. Thank you very much.

Thank you very much for your help. I called and tested it according to the way you provided to implement off-axis addition. I found that the display based on Poly was relatively correct. However, when I used dicom data to display voxel rendering, I couldn’t see the correct effect. The phenomenon was that only a very local picture was seen in the camera. And at this time, the vtkRenderWindowInteractor seemed not to work. I couldn’t zoom out the camera through the mouse to see the full picture. How should I control the camera in this case? Do I need to write an Interactor based on controlling the eyeposition by myself?

I’m not aware of any built-in interactor styles in VTK that manipulate the eye position. All the built-in interactorstyles in VTK (at least as far as I’m aware) just manipulate the Position, FocalPoint, and ViewUp properties of the camera, and as such, aren’t useful for off-axis projection. However, I’ve done a lot of work recently to improve head tracking and interaction in CAVE environments, and there, head tracking is achieved by invoking camera->SetEyeTransformMatrix(). Using that information as well as the EyeSeparation property, the camera computes actual eye positions (you can see how here [1]).

Interaction in CAVE environments isn’t managed in VTK, but rather in ParaView. Some better documentation is in the works [2], but the high-level summary is that in the CAVE, interaction is done by manipulating the ModelTransformMatrix property on the camera.

Along with better documentation I mentioned above, I’m also working on some basic examples of writing custom CAVE interactor styles in Python, which should help to better illustrate how you could achieve something similar.

I hope that helps.

Cheers,
Scott

[1] https://gitlab.kitware.com/vtk/vtk/-/blob/master/Rendering/Core/vtkCamera.cxx?ref_type=heads#L1937

[2] https://gitlab.kitware.com/paraview/paraview-docs/-/merge_requests/90/diffs