Hello,
Suppose I read a z-buffer value from the frame buffer, how can I
translate that into a distance from the observer, if I know the near and
far planes? Is this possible?
Thanks
|
|
0
|
|
|
|
Reply
|
Makhno
|
4/20/2007 5:29:44 PM |
|
On Apr 20, 7:29 pm, Makhno <r...@127.0.0.1> wrote:
> Hello,
> Suppose I read a z-buffer value from the frame buffer, how can I
> translate that into a distance from the observer, if I know the near and
> far planes? Is this possible?
>
> Thanks
gluUnproject()
|
|
0
|
|
|
|
Reply
|
fungus
|
4/20/2007 6:56:13 PM
|
|
>> Hello,
>> Suppose I read a z-buffer value from the frame buffer, how can I
>> translate that into a distance from the observer, if I know the near and
>> far planes? Is this possible?
>
> gluUnproject()
Obvious, now I think about it!
But suppose I need to do it to a lot of pixels (eg: all of them) what is
the performance like? As I understand it, gluUnproject is a couple of
matrix calculations per call.
Is there a way to at least get an approximate answer? At the moment, I'm
just assuming z is a linear proportion between the near and far planes
which....almost works....
|
|
0
|
|
|
|
Reply
|
Makhno
|
4/20/2007 9:39:57 PM
|
|
"Makhno" <root@127.0.0.1> wrote in message
news:WJmdnW0HWuakrrTbRVnysQA@bt.com...
>>> Hello,
>>> Suppose I read a z-buffer value from the frame buffer, how can I
>>> translate that into a distance from the observer, if I know the near and
>>> far planes? Is this possible?
>>
>> gluUnproject()
>
> Obvious, now I think about it!
> But suppose I need to do it to a lot of pixels (eg: all of them) what is
> the performance like? As I understand it, gluUnproject is a couple of
> matrix calculations per call.
>
> Is there a way to at least get an approximate answer? At the moment, I'm
> just assuming z is a linear proportion between the near and far planes
> which....almost works....
A couple matrix calculations/pixel, a million pixels, many tens of
megaflops+ cpu -- no worries.
Probably faster than the readback time. gluUnproject no doubt could be
optimized.
jbw
|
|
0
|
|
|
|
Reply
|
jbwest
|
4/21/2007 2:08:14 AM
|
|
>> But suppose I need to do it to a lot of pixels (eg: all of them) what is
>> the performance like? As I understand it, gluUnproject is a couple of
>> matrix calculations per call.
>
> A couple matrix calculations/pixel, a million pixels, many tens of
> megaflops+ cpu -- no worries.
> Probably faster than the readback time. gluUnproject no doubt could be
> optimized.
It causes a noticeable jolt on a realtime application even when my
buffer is only 256x512 and that's on a high-end system.
|
|
0
|
|
|
|
Reply
|
Makhno
|
4/21/2007 2:56:21 PM
|
|
On Apr 20, 11:39 pm, Makhno <r...@127.0.0.1> wrote:
> > gluUnproject()
>
> Obvious, now I think about it!
> But suppose I need to do it to a lot of pixels (eg: all of them) what is
> the performance like? As I understand it, gluUnproject is a couple of
> matrix calculations per call.
>
Yes, it will be wasteful to keep on inverting the exact
same matrix, etc. for every single pixel. If you want to
do millions of them then it might be a good idea to
"inline" the function. If you don't know how to do the
math then maybe you could get the source code off
the web (either the SGI version or MESA).
> Is there a way to at least get an approximate answer?
I don't think so.
> At the moment, I'm just assuming z is a linear proportion
> between the near and far planes
In a 3D view it's definitely *not* linear.
--
<\___/>
/ O O \
\_____/ FTB. Remove my socks for email address.
|
|
0
|
|
|
|
Reply
|
fungus
|
4/21/2007 3:00:52 PM
|
|
>> But suppose I need to do it to a lot of pixels (eg: all of them) what is
>> the performance like? As I understand it, gluUnproject is a couple of
>> matrix calculations per call.
>
> Yes, it will be wasteful to keep on inverting the exact
> same matrix, etc. for every single pixel.
I did the unprojection myself, and performance looks tolerable. How it
manages in my real application where the buffer is several times bigger
I'll have to wait until Monday to see.
>> At the moment, I'm just assuming z is a linear proportion
>> between the near and far planes
>
> In a 3D view it's definitely *not* linear.
In my case it was tolerable as the near and far planes were both a long
way from the observer and quite close. Comparing output where I handle
it properly and where I do not, the results are very similar (just
slightly different).
I wanted to extend the range for some future work, and this would make
the difference quite large, hence the question.
Thank you ~
|
|
0
|
|
|
|
Reply
|
Makhno
|
4/21/2007 3:25:11 PM
|
|
Assuming you are using high-end hardware (and shaders)...
You could write the world-space position to a vertex attribute which
is then interpolated for each fragment. If you write this value to a
32-bit per channel ancillary buffer (render target), you would only
have to read that buffer back once to get the world-space position of
every pixel on the screen.
Regards,
- Nick
On Apr 21, 10:56 pm, Makhno <r...@127.0.0.1> wrote:
> >> But suppose I need to do it to a lot of pixels (eg: all of them) what is
> >> the performance like? As I understand it, gluUnproject is a couple of
> >> matrix calculations per call.
>
> > A couple matrix calculations/pixel, a million pixels, many tens of
> > megaflops+ cpu -- no worries.
> > Probably faster than the readback time. gluUnproject no doubt could be
> > optimized.
>
> It causes a noticeable jolt on a realtime application even when my
> buffer is only 256x512 and that's on a high-end system.
|
|
0
|
|
|
|
Reply
|
gamefreedom
|
4/22/2007 10:05:02 AM
|
|
gamefreedom@gmail.com wrote:
> Assuming you are using high-end hardware (and shaders)...
>
> You could write the world-space position to a vertex attribute which
> is then interpolated for each fragment. If you write this value to a
> 32-bit per channel ancillary buffer (render target), you would only
> have to read that buffer back once to get the world-space position of
> every pixel on the screen.
I had thought about using a pixel shader, but there are other
calculations done on a per-pixel basis, and I'm not sure a pixel shader
can do all that's needed.
One day I'll investigate further...
|
|
0
|
|
|
|
Reply
|
Makhno
|
4/22/2007 7:15:22 PM
|
|
|
8 Replies
199 Views
(page loaded in 0.116 seconds)
Similiar Articles: Pixel Calculation - comp.soft-sys.matlab... of > anyway of relating pixels in an image to a real distance. ... find centroid ... any* pixel of an image to any value ... ... Site Map : The Pixel Calculator is intended ... Fisheye - comp.graphics.api.openglThe distance is calculated to allow proper depth culling using the z-buffer. ... spherical texture mapping in OpenGL - comp.graphics ... Random access to content of archived files without extraction ...Lets have M = sqrt(N) (you can choose whatever value ... allow you to start decompressing some short distance ... sectors with "real" sector numbers exceeding mapping to real ... convert pixel to cm - comp.soft-sys.matlab... galaxy from a telescope they'll have different real ... bar that the microscope puts on there, or a known distance ... comments made about needing to know a reference value ... Render to depth texture - comp.graphics.api.openglhttp://www.topaz3d.com/ - New 3D editor for real time ... to depth texture - comp.graphics.api.opengl Depth-map ... you need to bind an extra > texture to the Z buffer. Alpha blending with depth buffer - comp.graphics.api.opengl ...Then you preserve these depth values by making the ... any projection, so that, for example, the distance of the ... - The Bakers' Home Page Alpha-blending and the Z-buffer. renderbuffer objects - comp.graphics.api.opengl1) I am confused about the values of the depth component. ... am making to set up the fbo in my app. > the z-buffer is ... of GLEW are wrong but I think this would lead to real ... Stereoscopic Mouse Cursor !!! - comp.graphics.api.opengl ...I use a Zbuffer readback to get the near Z ... The values are just too small, say 0.0031 for 657 in real coordinates. ... Does anyone know how to map the ... Comparison of a Simple Join done by EG and Hand Coded - 22 times ...... on condition in SQL are powerful constructs which map ... people who can recognize a computer from a distance, but ... add arguments, for instance if I want a default value ... 2D interpolation - comp.soft-sys.matlabHere is a newbie to 2D interpolation and this is a real simple ... with pixel matching ... on each of the 4 pixel values is based on the computed pixel's distance (in 2D ... Z-buffering - Wikipedia, the free encyclopedia... ghostly passing through wall" effects, and complex effects like mapping of ... enough granularity, quality problems may arise when precision in the z-buffer's distance values ... MapQuest Maps - Driving Directions - MapUse MapQuest for driving directions and maps. See local traffic and road conditions ... Real Estate: Travel: Apartments: Airline Tickets: Movies 7/23/2012 10:21:57 PM
|