Depth/stencil value under vp/fp

I’m missing some vp/fp functinality and wondering - is there something wrong with the functionality - and it never will be available…

Under fragment/vertex program and similar:

Readonly access to

  1. depth value under current fragment.
    Assumed state: early depth test is working (no altering of fragment depth in fragment programm [or whatever limitations happen to be there]).

The advantages of this are significant (fog / water / light and shadows in fog / basicaly anything volume related [also: most of it is currently under reasonable framerates totally impossible todo {I mean - doing it so that it doesn’t look like s*** AND not in a horribly limited situation}]) - yet, noone seems to provide it.

I can’t see any reason why tho. How hard it is to give the depth value from early depth test to fragment program? What does prevent that !?

I’l give a candy to the one who makes a extension for it. Who is with me?

  1. stencil value for current fragment.
    Assumed state: stencil testing is active.

Also, can’t see a reason why not to give that value (it even fits nicely into ogl specification!).

Am i missing something that prevents that?

(Currently i’m copying [Sic!] it out to client memory [Sic!] and reposting [Sic!] it back as a bigger-than-needed texture [Sic!] and wasting a texture unit/access [Sic!] and projecting cordinates for it in fragment/vertex program. [Sic!])

NB! English is not my native language.

I’ve also been dying to have this ability, but there seem to be hardware restrictions that currently prevent the framebuffer depth/stencil values from being fed into fragment programs.

What you’re going to have to do for now is copy the depth buffer to a RECT texture using the glCopyTexSubImage function. Prepare a screen-sized depth texture ahead of time, and just do the copy once per frame. I’ve found that it really doesn’t take much time at all because you’re doing a VRAM-to-VRAM copy. Just use the texture (with filtering set to GL_NEAREST) in your fragment program and address it with the fragment.position register.

/…/Prepare a screen-sized depth texture ahead of time, and just do the copy once per frame./…/
To do what i intend to-do (light and shadows in fog volumes) i need to copy it several dozens of times. :frowning: So far - i think it will be too slow => can’t do. But a single (boring) layer of simple fog should be ok - i think.

Is there a way (that i haven’t noticed so far) to get the sencil value without reading back (witch causes glFinish and blocks my program) something from ogl?

(i wish that the hardware restrictions get fixed/overcomed soon … :frowning: )

The only way that I know to get the stencil values into a texture is to use the GL_NV_copy_depth_to_color extension to copy stencil values into the alpha channel of the color buffer. Then use glCopyTexSubImage to copy the alpha channel into an alpha texture. I’m actually doing this for some penumbral shadow stuff that I’m working on, but unfortunately it can only be done on Nvidia hardware.

:stuck_out_tongue: Yeah, that would likely help (at least - the test runs would not lag that much. [copy per shadowing solution {or how is that called}]) … if i would have some Nvidia hardware around :frowning: