OpenGLGPUVolumeRayCastMapper : rendering is not working


Hi everyone,

I’m working on replace the vtkFixedPointVolumeRayCastMapper with the vtkOpenGLGPUVolumeRayCastMapper and I found something weird.

First of all you have to know that i’m doing some transformations on the vtkCamera and the “bugs” occur when the transformations are on.

The transformations :
double vflip[16];
double hflip[16];
double reverse[16];
vflip[5] = -1;
hflip[0] = -1;
reverse[10] = -1;



transform3->Concatenate(reverse) ;

Without transformation but with the vtkOpenGLGPUVolumeRayCastMapper :

With transformation 1 and vtkOpenGLGPUVolumeRayCastMapper :


Now just compare with the vtkFixedPointVolumeRayCastMapper :

Without transformation : image
(You can also see that the transfer function is not computed in the same way but we don’t care here)

With transformation 1 :

Do you have any idea on what is happening here with this vtkOpenGLGPUVolumeRayCastMapper ?

1 Like
(Simon Drouin) #3

I remember having trouble with GPU ray casting when using a flipping transform (e.g. scale -1), so I avoid it now. My theory is that GPU raycast rendering work by drawing the bounding box of the volume. The -1 scale flips normal and since backfaces are now outside, they don’t get drawn. But I haven’t verified in the code if this is actually what is going on. If it is the case, it wouldn’t be difficult to fix.


Thanks for your answer @Simon
That’s actually something I saw trying to understand what was going on. I was about to post that the problem was probably occurring because the ray casting wasn’t working well with the flip.

I made some researches about this and your theory and I found people saying (from OpenGL forum) the GPU Raycast is rendering the front and the back of the box to initialize the ray casting : " The initial stage is to compute a texture that represents the direction of the ray for each pixel. It is done drawing the front and back faces of the bounding box of the volume dataset. "

I guess this is about the normals being in the wrong orientation so the raycasting is not working ?

Do you have any idea where I can check this in the Mapper and how I can fix this ? This is something I need to solve because I need to apply those flips in my project.

Thank you for answering me.

(Andras Lasso) #5

At many places, VTK assumes that you use a right-handed coordinate system. Applying a transform that has negative determinant (for example, flip around a single axis) violates this assumption and leads to various errors.

In some image readers, you can choose to flip the order of slices. If that is not an option then you probably need to reslice the volume (see vtkImageFlip and vtkImageReslice filters).