Z-Buffer. How to access it?

BlitzMax Forums/MiniB3D Module/Z-Buffer. How to access it?

SystemError51(Posted 2012) [#1]
Hi all,

title says all. I'm experimenting around with things like creating a shadow map, and I was wondering if there is any way to access Z-buffer data? Can you do that at all? Or do you have to find your own way?


Thanks for your help (again) :)


AdamRedwoods(Posted 2012) [#2]
glReadPixels or FBOs. glReadPixels does not work for depth buffers in OpenGL ES (mobile).

http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml

if you are moving your shadow map to a texture, best to use FBOs.


Kryzon(Posted 2012) [#3]
Yeah, while you educate yourself on FBOs you'll see there's a part called "Depth Attachment", a texture attachment where depth information is written to and from which you can read with a fragment shader to get color values.

FBOs are also used for plenty of other fullscreen effects, so they are definitely a good choice to learn.

There's some BlitzMax literature, along with what you can find on the web:
http://blitzbasic.com/Community/posts.php?topic=85608
http://www.blitzbasic.com/Community/posts.php?topic=94635
http://www.blitzbasic.com/Community/posts.php?topic=69804


SystemError51(Posted 2012) [#4]
Thanks again for your pointers :) I'll read up on those.