Hello... Two questions of Z-buffer..
HI
1- How can I see the Num of bits in my Z buffer (16,24,32?)....
2- OPENGL uses a formula (with z-near, z-far, etc...) to calculate the z-buffer values (in the range 0..1).
How can obtain this formula?....
Alert
Thanks
1- How can I see the Num of bits in my Z buffer (16,24,32?)....
2- OPENGL uses a formula (with z-near, z-far, etc...) to calculate the z-buffer values (in the range 0..1).
How can obtain this formula?....
Alert
Thanks
1. glGetIntegerv(GL_DEPTH_BITS, pointer), pointer must be a pointer to a GLint array. The result will be writen into that array. But normaly you select the number of bit when you choose your pixel format.
Keep in mind the number of bits you ask for might not be the number of bits you actually get.
As for depth calculation formula, I think it's z/w (the fourth coordinate of a vector) with respect to the near plane in some way, but I can't find it. I think it's in the red book somewhere, though.
Oh, try "man glDepthRange" in the terminal. However, why do you want this formula? Why isn't just the Z values OK? Perhaps there is a better way to do what you want?
Oh, try "man glDepthRange" in the terminal. However, why do you want this formula? Why isn't just the Z values OK? Perhaps there is a better way to do what you want?
When change z-near or z-far values in a ortho view , the behavior of depht-values is a non-linear function (is a exponential function in the range 0..1)..
I want the control of this function!!!!!
So , this... I need obtain the formula how Z-buffer obtain the values, to make linear this function (or almost) .... hehe
Thanks
I want the control of this function!!!!!
So , this... I need obtain the formula how Z-buffer obtain the values, to make linear this function (or almost) .... hehe
Thanks
The formula is given in the GL spec, section 2.11.1 "Controlling the Viewport":
z = [(f - n)/2]zd + (n + f)/2
where n and f are the near and far planes specified by glDepthRange, and zd is the normalized device Z after MVP.
You can not change this formula in the fixed-function GL pipeline. Of course in a fragment program you are free to write any depth value you choose, although this will have detrimental effects on performance on hardware that performs early-Z rejection.
You still haven't said what you're trying to do, though. There may be a better solution.
See for example one, two, three, four.
z = [(f - n)/2]zd + (n + f)/2
where n and f are the near and far planes specified by glDepthRange, and zd is the normalized device Z after MVP.
You can not change this formula in the fixed-function GL pipeline. Of course in a fragment program you are free to write any depth value you choose, although this will have detrimental effects on performance on hardware that performs early-Z rejection.
You still haven't said what you're trying to do, though. There may be a better solution.
See for example one, two, three, four.

