I’m having issues with the vtkOpenGLGPUVolumeRayCastMapper class. What seems to work with the vtkFixedPointVolumeRaycastMapper doesn’t seem to work with the GPU variant.
To be more precise, I’m flipping the X and Y axis of the vtkCamera projection transform by setting the 0th and 5th values of the matrix to -1
Here are some screenshots of it working perfectly with the vtkFixedPointVolumeRaycastMapper:
When only flipping X or Y we can see the tips of the model, so it’s almost working but not quite.
Seemingly the signs cancel when flipping both X and Y, which makes things work again?
On a probably related note, I’m also having issues with the lighting when reversing the Z axis.
I’ve taken a look at the shader of vtkOpenGLGPUVolumeRayCastMapper but did not manage to figure out why would this happen.
What I’m doing is similar to what’s being done in this thread:
It also works for CPU volume rendering (unfortunately, ray computation seem to be implemented with some custom logic in the GPU volume renderer, so that would need some fixes).
seems to imply that it would be possible to fix, if that’s the case what would be the potential fix or lead to explore?
Yes, GPU volume rendering ray computation would need an update to allow reverse perspective rendering. This rendering mode is essential for fluoroscopy fusion applications, but not for much else, so waiting for some project to fund the development could take years. If you need it sooner then you can try to implement it yourself or give a small contract to Kitware or other developers experienced with VTK rendering to implement it for you.
Regarding the computation of rayOrigin you pointed to, by default UseDepthPass is turned off so this part of the shader is not executed from my observations (I’m outputing the compiled shader to file inside the BuildShader method, I’m not sure this is the best method but I haven’t found another solution)
Simply enabling UseDepthPass seems to break the rendering. Barely anything renders:
Sorry for the late reply. I think the reason why it works better with the depth pass is because the ray origin is computed by taking the projection matrix into account in this case (see here). Maybe a similar approach can be implemented without using the depth pass, but then there will be probably other issues with lighting, clipping,…
Just to understand the use case, could flipping the image on the CPU with vtkImageFlip be an option? or does it really have to be done at the rendering step?
Flipping the image is not an option, as all the sizes are correct as they are (anterior part of the patient is farther from the generator, so magnification factor is smaller than for the posterior side), but the clinician usually wants to see the anterior part appear in the front (occluding the posterior side).
Everything (lighting, etc.) works well for surface rendering, and even for volume rendering with the CPU mapper. Only the GPU mapper is broken with reverse persepective projection.