[vtkusers] transparent 3D over 2D

David Gobbi david.gobbi at gmail.com
Fri Jul 8 17:48:50 EDT 2011


Hi Chris,

Calling SetDisplayLocationToBackground() does not cause the image
to be rendered first.  In VTK, the 2D actors are always rendered last.
All that SetDisplayLocationToBackground() does is change the depth
buffer value that is used when the 2D actor is rendered.

The order in which actors/actor2Ds are added only matters for things
that are drawn in the same pass.  As I mentioned above, 2D actors
are always drawn in the final pass.

The reason that the image ended up obscuring the geometry is that,
VTK does not write to the depth buffer in the translucent pass...
combine this with the fact that the image is drawn last, and the
image obscures the geometry.  I had forgotten about this issue.

So now that I consider the issue, I don't know if there is an easy
solution.  This would all be fairly simple if VTK had an underlay
pass, but it doesn't... it tries to "fake" an underlay pass by
rendering a 2D overlay just in front of the rear clipping plane (!!).

So the only fix, which is counterintuitive, is to do the overlay with
two renderers.  Just add two renderers to your RenderWindow where you
would usually just add one.  The first renderer you add will render
first.  The second renderer will render over top.  Image in the first,
translucent geometry in the second.

Let me know if that works.

 - David

On Fri, Jul 8, 2011 at 3:22 PM, Chris Volpe ARA/SED <cvolpe at ara.com> wrote:
> David-
>
>
>
> Unless I have misunderstood something, the image rendering is clearly being
> done first, because I have SetDisplayLocationToBackground() on the Actor2D’s
> property. If my geometry were not being rendered in the translucent pass (I
> didn’t even know there *was* a “translucent pass” – thanks for the info!),
> would I still be able to see one piece of geometry through another?
>
>
>
> Anyway, I tried what you said – setting the opacity to  .995 on the
> geometry’s actor’s property – and that made it worse. Now, all of a sudden,
> the image is no longer drawn in the background – it’s obscuring all the
> geometry.
>
>
>
> Does the order in which the Actors and Actor2Ds get added to the renderer
> matter?
>
>
>
> Thanks,
>
> -Chris
>
>
>
> From: David Gobbi [mailto:david.gobbi at gmail.com]
> Sent: Friday, July 08, 2011 3:12 PM
>
> To: Chris Volpe ARA/SED
> Cc: vtkusers
> Subject: Re: [vtkusers] transparent 3D over 2D
>
>
>
> Then the problem is the order in which the items are rendered.  Perhaps your
> geometry is not being rendered in the translucent pass.  If you set the
> Opacity in the property to 0.995, that will force the geometry to be
> rendered in the translucent pass, i.e. after all opaque geometry has already
> rendered.  It is the Opacity of the property, rather than the alpha of the
> lookup table, that VTK uses to decide whether to use the translucent pass.
>
>
>
> What is probably happening in your case is that the geometry is rendered
> first, causing a write to the depth buffer.  Then the image is drawn
> afterwards, and the depth buffer check causes it not to be written to any
> pixels that the geometry rendered to.
>
>
>
>  - David
>
>
>
>
>
> On Fri, Jul 8, 2011 at 12:29 PM, Chris Volpe ARA/SED <cvolpe at ara.com> wrote:
>
> If depth peeling is something that's off by default, unless you explicitly
> enable it, then I'm not doing it. (In fact, I've never heard of it.) I just
> have 3D geometry with a color lookup table that varies the hue but keeps
> alpha constant at 0.5.
>
>
> -Chris
>
>> -----Original Message-----
>> From: David Gobbi [mailto:david.gobbi at gmail.com]
>> Sent: Friday, July 08, 2011 12:43 PM
>> To: Chris Volpe ARA/SED
>> Cc: vtkusers
>> Subject: Re: [vtkusers] transparent 3D over 2D
>>
>> Are you using depth peeling?  Depth peeling disables alpha, it is an
>> alternate strategy to translucent rendering that doesn't use alpha and
>> as far as I understand, it actually requires alpha-blending to turned
>> off in order to work.
>>
>> So I don't think that depth peeling can be used when an underlay is
>> present (or at least, not in VTK).
>>
>>  - David
>>
>>
>> On Fri, Jul 8, 2011 at 10:32 AM, Chris Volpe ARA/SED <cvolpe at ara.com>
>> wrote:
>> > I'm rendering 3D geometry over a 2D image drawn onto the rendering
>> window
>> > using an Actor2D. The 3D geometry  is semi transparent, as can be
>> seen when
>> > some 3D geometry is drawn on top of other 3D geometry. However, the
>> > transparency does not permit seeing the background image through the
>> 3D
>> > geometry. For purposes of the background image, the 3D geometry is
>> > completely opaque. Is this an inherent limitation, or am I doing
>> something
>> > wrong?
>> >
>> >
>> >
>> > Thanks,
>> >
>> >
>> >
>> > Chris
>> >
>> > --
>> > Christopher R. Volpe,
>> > Ph.D.
>> Email:
>> > cvolpe at ara.com
>> >
>> > Senior Scientist, Information Exploitation Systems             Main
>> Desk:
>> > 919-582-3300
>> >
>> > Applied Research Associates,
>> > Inc                                                     Direct: 919-
>> 582-3380
>> >
>> > 8537 Six Forks Rd., Suite
>> > 6000                                                            Fax :
>> > 919-582-3301
>> >
>> > Raleigh, NC 27615                                         Web:
>> > http://www.ara.com/offices/NC.htm
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list