Re: Identifying pixels
- From: "jbwest" <jbwest@xxxxxxxxxxx>
- Date: Wed, 26 Oct 2005 07:39:27 -0700
"Dave" <workmad3@xxxxxxxxxxxx> wrote in message
news:djo128$oto$1@xxxxxxxxxxxxxxxxxxxxxxx
> fungus wrote:
> > Athanasios Mantes wrote:
> >
> >> Hi all,
> >>
> >> I have a 3d scene with various objects rendered, and I'm trying to do
> >> the following: render a small tooltip that shows the distance of the
> >> camera to the point in 3d space that corresponds to the pixel the
> >> mouse points. I know that I have to get the z buffer for the pixel,
> >> use gluUnproject etc, but my problem is this: since moving the mouse
> >> doesn't cause the scene to re-render, I can't get the z buffer value
> >> for an arbitrary pixel, without rendering the scene first, and reading
> >> the depth component pixel value for the specific pixel. Of course,
> >> rendering the scene for every mouse move is not desired (as many of
> >> you pointed out in a previous post), but I don't see another way, and
> >> reading the depth value for all pixels, is slow.
> >>
> >
> > Why can't you read the depth buffer more than once
> > (ie. without re-rendering)?
> >
> iirc, its mainly due to the buffers not having been specified te be in
> any particular state once they have been flushed to the screen.
> Basically if you use it after it has been rendered, it could have
> anything in there depending on how the implementation decided to treat
> buffers after a flush.
Not true! The Z buffer is completely correct after a swapbuffers! The
*back buffer* is undefined, but the front- and z- buffers are completely
specificed. You can use that property to draw to the frontbuffer with full
z-buffering, or read back the z-buffer values of anywhere on the current
scene.
I've done that for many years, using the Z-buffer to provide an XYZ "lazy
cursor" in object space in complex scenes where raycasting would be too
slow, and also to implement XOR z-buffered "probes".
If you "pop up" the tooltip over the scene, save the Zbuffer and
frontbuffer contents first, and put them back after you pop down the tool
tip so that there's no damage and you don't have to re-render for the next
tooltip.
jbw
.
- References:
- Identifying pixels
- From: Athanasios Mantes
- Re: Identifying pixels
- From: fungus
- Re: Identifying pixels
- From: Dave
- Identifying pixels
- Prev by Date: Re: Identifying pixels
- Next by Date: Re: renderbuffer objects and the depth buffer, gamma correction needed?
- Previous by thread: Re: Identifying pixels
- Next by thread: Re: Identifying pixels
- Index(es):
Relevant Pages
|