When I have an image placed exactly in the XY plane, and I view it from the z-axis. It disappears if there is nothing else in the scene. If I add some other actor, then it does render it. What I’ve noticed is that if I zoom out a lot, it becomes visible again. Is it clipping the image? Thanks in advanced.
Yes, I’m sure now that it’s a near/far clipping plane issue.
If you do not set up the camera yourself, then VTK will automatically set up the camera based on the actor bounds during the first render. For vtkImageActor, the bounds are set from the DisplayExtent of the actor. Since the DisplayExtent is a single slice, this causes the near and far clipping planes to be very tightly positioned in front of and behind the slice.
There are certain interactions that cause the interactor to reset the clipping planes (I can’t recall which), but it’s very easy for at least part of the vtkImageActor to move beyond the clipping planes. There are two work-arounds for this:
Set up the camera yourself before the first render, and set the clipping range to be large enough to contain the whole image from any angle.
Use vtkOutlineFilter to create a frame around the image data (use the image data as the input to vtkOutlineFilter, and for the outline actor, use the same UserTransform as for the image actor). This extra actor will cause VTK to initialize the near/far clipping to better values. You can make it transparent if you don’t actually want it to be visible.
Thanks for the suggestion. I tried doing the second one, but once I make the frame invisible, the clipping problem returns
In terms of the first suggestion, would I have to compute the clipping plane based on the position of the camera with respect to the visuals? I sometimes also render other objects along the image (and in some scenarios, multiple images). Would one require to also compute the clipping range when the user zooms in and out?