I’m working on a vtk application which generates oblique views (by turning parallel projection on and setting view shear in the camera) and discovered that vtkGPUVolumeRayCastMapper does not appear to handle cameras with view shear, resulting in a rendered oblique view which seems to cast rays in the wrong direction. I tracked the issue down to vtkOpenGLGPUVolumeRayCastMapper::SetCameraShaderParameters. In this method, a projection direction is passed to the shader. Currently, the code calls vtkCamera::GetDirectionOfProjection to get this value. However, this value stored in the camera does not get updated when view shear is set on the camera, so the view plane normal that is calculated from view shear does not line up with the direction of projection.
I changed the following lines in vtkOpenGLGPUVolumeRayCastMapper::SetCameraShaderParameters from:
cam->GetDirectionOfProjection(dir);
vtkInternal::ToFloat(dir[0], dir[1], dir[2], fvalue3);
to:
cam->GetViewPlaneNormal(dir);
vtkInternal::ToFloat(-dir[0], -dir[1], -dir[2], fvalue3);
This appeared to fix the issue and my oblique views were being generated correctly. It is worth noting that the vtkFixedPointVolumeRayCastMapper does not exhibit this same issue.
I wanted to bring this issue to the attention of the group in the hopes that a fix could be implemented in a future release.
Cheers,
Matt