View Full Version : Depth Buffer Reading
11-07-2000, 06:26 AM
I'm implementing the dynamic LOD algorithm Occluder Shadows, which consists of reading back from the depth buffer (on my Geforce II). I'm currently using glReadPixels(), but it's very slow. Is there a faster way of reading back from the depth buffer, or would I be better to use Software Rasteraztion instead.
As far as I know, glReadPixels is the only way to access the depth buffer...
I do not know what the algorithm you are using involves but what do you exactly do when reading the buffer ?
1) Do you read the whole buffer at once and then work on it ?
2) Do you read parts of the buffer several time ?
If you are doing 2), perhaps you should try to read the whole buffer only once as described in 1)... It should be faster than multiple "mini"-glReadPixels (on this one, nVidia guys will answer better than me !).
If you need to read it at different stages of your rendering process, then I guess you have to stick to multiple "mini"-reads...
Now, if you are already reading the whole buffer at once and it is too slow, I have no idea...
I don't think switching to software mode would help: you do not have direct access to the depth buffer either if you use Microsoft GDI Generic implementation (although I am sure there is a dirty hack to find in this case !).
11-07-2000, 08:11 AM
How slow is very slow? That should actually run at a reasonable speed (tens of megapixels per second). Make sure you're reading back into a fixed-point format, though. Floats will introduce extra conversions.
DJ Tricky S
11-07-2000, 11:39 AM
In the game I am working on we used glReadPixels to check depth buffer values for determining visibility of certain things in screen-space coordinates. Certain hardware handles this nicely (read: very little speed hit), nvidia hardware for example. Other hardware takes a massive speed hit for reading from the back buffer (3Dfx comes to mind). This is definiately a feature of your app that is definately going to vary greatly across hardware.
DJ Tricky S
11-07-2000, 11:41 AM
sorry for the incoherency in my post, I just read it and it shows how sleep deprived I am feeling right now, heh.
11-08-2000, 07:24 AM
You could also use the accumulation buffer to grab the depth buffer which might be faster but I don't know whether this would help with what you are doing or not http://www.opengl.org/discussion_boards/ubb/smile.gif
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.