|
|
Writing to depth buffer
Hi!
I'm writing an application which needs to write depth information to the
depth buffer. AFAIK is there no linear mapping from depth to the value, I
must write to the buffer. Therefore: How can I compute the depth
buffer-value from the depth value?
thx
Markus Doerschmidt
|
|
0
|
|
|
|
Reply
|
markus.doerschmidt (3)
|
11/8/2004 7:46:23 AM |
|
Markus D�rschmidt wrote:
> Hi!
>
> I'm writing an application which needs to write depth information to the
> depth buffer. AFAIK is there no linear mapping from depth to the value, I
> must write to the buffer. Therefore: How can I compute the depth
> buffer-value from the depth value?
>
It's not easy...
You could use gluProject() to generate a table
of depth values to use as a base for a table
based lookup.
--
<\___/> For email, remove my socks.
/ O O \
\_____/ FTB. The Cheat is not dead!
|
|
0
|
|
|
|
Reply
|
fungus
|
11/8/2004 12:32:30 PM
|
|
On Mon, 8 Nov 2004 08:46:23 +0100, "Markus D�rschmidt"
<markus.doerschmidt@gmx.de> wrote:
>I'm writing an application which needs to write depth information to the
>depth buffer. AFAIK is there no linear mapping from depth to the value, I
>must write to the buffer. Therefore: How can I compute the depth
>buffer-value from the depth value?
Isn't it true that that you can apply -any- monotonically increasing
mapping between your desired value and the 'depth' you write into the
depth buffer & it will have the same effect (apart from resolution)?
Um, and-- as long as the endpoint mapping is 0.0-> 0.0 and 1.0->1.0.
I'd think that would give you enough freedom to find a linear mapping
that would do the job...
Matt Feinstein
--
There is no virtue in believing something that can be proved to be true.
|
|
0
|
|
|
|
Reply
|
Matt
|
11/8/2004 12:55:56 PM
|
|
Matt Feinstein wrote:
> On Mon, 8 Nov 2004 08:46:23 +0100, "Markus D�rschmidt"
> <markus.doerschmidt@gmx.de> wrote:
>
>
>>I'm writing an application which needs to write depth information to the
>>depth buffer. AFAIK is there no linear mapping from depth to the value, I
>>must write to the buffer. Therefore: How can I compute the depth
>>buffer-value from the depth value?
>
>
> Isn't it true that that you can apply -any- monotonically increasing
> mapping between your desired value and the 'depth' you write into the
> depth buffer & it will have the same effect (apart from resolution)?
>
>
Yes, but people who do this usually want to draw
something else on the top of it.
--
<\___/> For email, remove my socks.
/ O O \
\_____/ FTB. The Cheat is not dead!
|
|
0
|
|
|
|
Reply
|
fungus
|
11/8/2004 1:06:30 PM
|
|
Writing depth values with an any monotonically increasing mapping would
cause problems in drawing an object in the scene.
Is there no specification how the depth values are mapped to the depth
buffer? Does each OpenGL implementation handle this in another way?
thx
Markus
|
|
0
|
|
|
|
Reply
|
Markus
|
11/9/2004 8:08:06 AM
|
|
Markus D�rschmidt wrote:
> Writing depth values with an any monotonically increasing mapping would
> cause problems in drawing an object in the scene.
>
Correct.
> Is there no specification how the depth values are mapped to the depth
> buffer? Does each OpenGL implementation handle this in another way?
>
They all do it the same way (I think), the
problem is that there's no nice simple formula
for it.
--
<\___/> For email, remove my socks.
/ O O \
\_____/ FTB. The Cheat is not dead!
|
|
0
|
|
|
|
Reply
|
fungus
|
11/9/2004 4:26:21 PM
|
|
fungus wrote:
> Markus D�rschmidt wrote:
>
>> Writing depth values with an any monotonically increasing mapping would
>> cause problems in drawing an object in the scene.
>>
>
> Correct.
>
>> Is there no specification how the depth values are mapped to the depth
>> buffer? Does each OpenGL implementation handle this in another way?
>>
>
> They all do it the same way (I think), the
> problem is that there's no nice simple formula
> for it.
Well, there have been implementations that used a W buffer instead of a
Z buffer, and there may well be differences in how the z values are
calculated. However, since many applications rely on gluProject and
gluUnProject (or similar code), the implementations would get lots of
bug reports unless they were at least close to the "usual" calculation.
I have not found many problems when reading back the depth buffer in
floating point or integer formats. However, my accuracy needs are fairly
low.
--
Andy V
|
|
0
|
|
|
|
Reply
|
Andy
|
11/10/2004 12:29:09 AM
|
|
|
6 Replies
154 Views
(page loaded in 0.097 seconds)
Similiar Articles: Write Depth Map to Depth buffer - comp.graphics.api.opengl ...Hi, I'm writting a program that would insert a 3D object in a 2D scene. To do that I need to write a previously calculated Depth Map to the Depth buffer. what is depth buffer? - comp.graphics.api.openglWrite Depth Map to Depth buffer - comp.graphics.api.opengl ... Hi, I'm writting a program that would insert a 3D object in a 2D scene. To do that I need to write a ... Alpha blending with depth buffer - comp.graphics.api.opengl ...Write Depth Map to Depth buffer - comp.graphics.api.opengl ... Write Depth Map to Depth buffer - comp.graphics.api.opengl ... Alpha blending with depth buffer - comp ... FBO: depth render buffer objects - comp.graphics.api.opengl ...Hi group, For creating a shadow map I've set up a depth render buffer object ... Write Depth Map to Depth buffer - comp.graphics.api.opengl ... FBO: depth render buffer ... Image processing the frame buffer under OpenGL - comp.graphics.api ...Write Depth Map to Depth buffer - comp.graphics.api.opengl ... Write Depth Map to Depth buffer - comp.graphics.api.opengl ..... know how to copy it to the depth buffer. Render to depth texture - comp.graphics.api.openglWrite Depth Map to Depth buffer - comp.graphics.api.opengl ... Render to depth texture - comp.graphics.api.opengl Write Depth Map to Depth buffer - comp.graphics.api.opengl ... still struggling with FBOs and depth texture (for shadow map ...Write Depth Map to Depth buffer - comp.graphics.api.opengl ..... comp.graphics.api.opengl If no stencil, disable depth buffer write. Draw the polygon. Dynamic overlays, Alpha test, Stencil test - comp.graphics.api ...You could render your pixels (with GL_POINTS) to the depth buffer setting ... Dynamic overlays, Alpha test, Stencil test. 2. Writing 0 or 1 to depth buffer only when passing ... renderbuffer objects - comp.graphics.api.opengl... as a part of the fbo extension) and know that they can be used to save the depth buffer. ... The fbo will automatically write the stuff to the texture. If you do not need to ... glpolygonoffset problem - comp.graphics.api.opengl1) at the same time. > Now draw the polygon except where the stencil buffer > is 1, clear the stencil buffer as you draw it. > > If no stencil, disable depth buffer write. Changing Depth Buffer Write AccessBy default, the Microsoft Direct3D system is allowed to write to the depth buffer. OpenGL FAQ / 12 The Depth Buffer12.030 How do I write a previously stored depth image to the depth buffer? Use the glDrawPixels() command, with the format parameter set to GL_DEPTH_COMPONENT. 7/9/2012 7:48:44 PM
|
|
|
|
|
|
|
|
|