[vtkusers] transparent 3D over 2D

Chris Volpe ARA/SED cvolpe at ara.com
Mon Jul 11 09:44:17 EDT 2011


That's the ticket! Thanks, David. I must be blind -- I looked on the vtkRenderer doxygen page for such a method, but I just didn't see it. I think I was looking for "clear", not "erase". 

-Chris


> -----Original Message-----
> From: David Gobbi [mailto:david.gobbi at gmail.com]
> Sent: Monday, July 11, 2011 9:39 AM
> To: Chris Volpe ARA/SED
> Cc: vtkusers
> Subject: Re: [vtkusers] transparent 3D over 2D
> 
> Hi Chris,
> 
> Try ren->EraseOff() on the second renderer, I checked through some of
> my own code and that is what I had been using when overlaying
> renderers.
> 
>  - David
> 
> 
> On Mon, Jul 11, 2011 at 6:46 AM, Chris Volpe ARA/SED <cvolpe at ara.com>
> wrote:
> > David-
> >
> > Thanks for the info. I created two renderers as you suggested and
> added them to the render window in the order you specified.
> Unfortunately, the background image (in the renderer added first) is
> not visible at all anymore. It's as if the second renderer clears the
> frame buffer entirely before rendering, thereby blowing away the output
> of the first renderer. Is there a way around that? If so, I think we'll
> have my problem solved!
> >
> > Thanks again,
> >
> > -Chris
> >
> >> -----Original Message-----
> >> From: David Gobbi [mailto:david.gobbi at gmail.com]
> >> Sent: Friday, July 08, 2011 5:49 PM
> >> To: Chris Volpe ARA/SED
> >> Cc: vtkusers
> >> Subject: Re: [vtkusers] transparent 3D over 2D
> >>
> >> 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
> >> >
> >> >
> > _______________________________________________
> > 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