View Full Version : gluPickMatrix and glReadPixels
02-16-2007, 07:36 AM
I use glReadPixels to read the depth component of the pixel under my mouse point, then multiply the return value by 2^32-1 and get value v1. Then I use gluPickMatrix to get the same pixel's minimum Z buffer value v2 from the select buffer. I find that v1 is slightly different from v2(about 1% error). Is there any fundamental mistake of my method or the error is in the range of allowance? Thank you!
02-16-2007, 07:51 AM
In most implementations, selection buffer is done in software. So yes it is rasterized differently.
Selection doesn't do any rasterization at all, so doesn't matter if it's hardware or not. Reading back a pixel relies on rasterization, but selection is purely a geometrical operation.
So the values are from different stages in the rendering pipe, so they are subject to different amount of calculations and roundings.
And then there's the issue that a primitive not perpendicular to the view vector has it's depth rasterized at the center of the pixel. Min/max depth as returned by selection will be at the edge of the pixel, which is different due to the fact that the depth varies over the primitive.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.