[vtkusers] vtkImageActor layers/bring to front?
David Gobbi
david.gobbi at gmail.com
Mon Feb 14 09:12:40 EST 2011
On Mon, Feb 14, 2011 at 7:06 AM, David Doria <daviddoria at gmail.com> wrote:
> On Mon, Feb 14, 2011 at 9:00 AM, Karthik Krishnan
> <karthik.krishnan at kitware.com> wrote:
>>
>> If the two images are at the same location in space, it seems like you
>> should blend the two images (vtkImageBlend) and then display it.
>>
>> If they are at different depths, you can achieve transparency either by
>> setting the opacity on both or on the actor closer to the camera to be
>> non-zero.
>> Alternatively to achieve transparency on selected regions of an image, you
>> can give it RGBA or LA (2 or 4 component) data. The last component will be
>> treated as alpha value for the pixel.
>>
>> I would suggest that you dither one of the images by a small amount.
>
>
> Hi Karthik,
> I don't want to blend them - I want to have the option to toggle which one
> is in front. They are both RGBA valued, with different alphas in different
> regions. So is the only way to achieve this to actually translate one of
> them to be in front of the other, and switch which one is translated to
> toggle which one is in front?
>
> David
Hi David,
It is possible to do what you are asking with vtkActors (i.e. by using a
vtkPlaneSource as the data and a vtkTexture with the the image), by
changing the order with which the two actors are added to the
renderer. It does not make it convenient to switch them, but it makes
it possible.
For vtkImageActor, though, the way that the depth buffer checks are
done seems to be different, and AFAIK doing an offset or using
vtkImageBlend like Karthik says are the best approaches.
Note that with either vtkActor or with vtkImageActor, you must set
the opacity to slightly below 1.0 (e.g SetOpacity(0.995) in order to get
VTK to turn on the alpha-blending in OpenGL.
- David
More information about the vtkusers
mailing list