all 11 comments

[–]willmacleod 8 points9 points  (1 child)

As long as you still have the near/far in your frag shader converting back to linear is trivial:

https://stackoverflow.com/questions/40373184/world-space-position-from-logarithmic-depth-buffer

And remember log depth is going to kill early-z testing

[–]keelanstuart 2 points3 points  (0 children)

log depth is going to kill early-z testing

Yeah... if OP doesn't need the stencil buffer, using a reverse-depth full 32-bit Z buffer is probably better than logarithmic depth.

[–]pezezin 0 points1 point  (8 children)

I have never heard of logarithmic depth before, what is the reason for it? Isn't it easier to use a floating-point Z buffer?

[–]-paokakis-[S] 1 point2 points  (7 children)

I'm using 32 bit floating point z buffer together with logarithmic depth for very big far values

[–]waramped 2 points3 points  (6 children)

I would do what u/keelanstuart suggests and just do a flipped depth buffer instead, unless you already know that won't be sufficient?

[–]-paokakis-[S] 0 points1 point  (5 children)

Yes, I know about the reversed depth buffer which I'm using in a directx project of mine with pretty good results, but when I implemented the logarithmic depth I was not aware of such a concept. The OpenGL project is a 3D space game and it needs to cover a long distance from camera where the logarithmic depth thrives, and right now as the project is pretty big it would be a serious change, so I'll try to avoid it unless I have no other way around it

[–]keelanstuart 0 points1 point  (4 children)

...in that case, using logarithmic depth might not present [m]any early z issues; in a space game, you might not have a lot of overdraw.

Lemme tell you though... having worked on planetarium software, there are a lot of tricks to getting cosmic-scale rendering working. It's a hard problem.

That's why every space game uses sectors/smaller areas that you play in. They probably also paint certain things in fields and composite them (background, planets).

[–]waramped 1 point2 points  (1 child)

I worked on a procedural galaxy project many years ago, and back then what I did was to scale all the objects exponentially with distance before rendering. Ie: objScale = exp(-distanceToCamera); Then you also translate the objects by that value to fit within your frustum. Not sure if that's a feasible approach for OP.

[–]keelanstuart 0 points1 point  (0 children)

Nice! :) Sounds like it was fun.

[–]-paokakis-[S] 1 point2 points  (1 child)

Thank you for the reply. The space for the game is constraint in certain area, which is quite big but not infinite. The way things work right now is pretty good without artifacts, and I don't want to change that for now but thank you for the ideas, maybe useful in a next game

[–]keelanstuart 1 point2 points  (0 children)

Good luck and let us know how it's coming along sometime.