I’m very beginner, so kind explanation and tolerance will be really appreciated.
I coded simple game with C++ and openGL.
And then, I want to calculate the depth of objects.
(to color them differently according to their depth)
I found the concept of z-buffer, and thought.
“Oh. Depth is already calculated! Just use it.”
But problem occurs.
Almost every objects has z-buffer in 0.9 ~ 1.0.
I noticed that the reason is non-linear distribution of z-buffer.
(May the designer of z-buffer wanted to calculate closer object more accurately, right?)
So, I linearized them with code.
After linearizing them, distribution be linear.
But other problem occurs.
Can you see?
Strange discontinuity ruined my graphic.
I suppose the reason is limited memory of z-buffer, but not sure.
So I decided just ignore z-buffer, and calculate it own way.
But is there any nice way to do it?
Or the problem above can be solved while still using z-buffer?
Please help me.
And I feel really sorry about do not post the part of my code here.
I do not have permission yet from my partners about it…
If I got it, then I would immediately post it.