I have a depth texture for shadowmapping that I want to draw on screen and debug. Is it enough just to do a conventional texture2D lookup to display the depth as an RGBA value, or do I have to do something special?
I believe so… IIRC depth textures are treated the same way as luminance textures.
Read the spec.
DEPTH_TEXTURE_MODE lets you draw the depth data as luminance, alpha, or intensity.
also u might wanna ampify the depth values as theyre most likely gonna be 0.99->1.0 + thus the texture will look white
eg something like
color = pow( depth_value, 100.0 );
draw a screen rectangle, then directly show it.
This is what I usually do if it’s just for debugging to get it into visible range. If you want to be more accurate though, you can compute the linear depth from the Z values.
And more, be careful about your near/far clip plane, maybe you will see a big white plane, scaled them to show gray level, much more clear.
Please forgive slight necro here…
I try using Humus’ equations to derive water depth for my shader, but just get black sea whatever I do… any tips at all?
You could try the match at the bottom of this thread (the Humus math does look OK tho):
Ah lol, it turns out that the built-in var gl_DepthRange isn’t being set properly for some reason (but containing a value which was neither higher, lower or equal to zero - presumably some sort of GLSL NAN value)!
Anyways… the equations are usable with my own hard-coded vals for near and far. I’m now seeing something whereby my water becomes more transparent as the camera distance increases:
I’m guessing this is a loss of accuracy in the depthVal as it moves away from the near plane. Would moving the near plane out as far as possible when rendering fix this maybe?
ed: if this is so, I presume I’m screwed when rendering beach scenes with near and far shallow water in it?!
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.