# How to achieve rendering at huge distances?

These days I was reading some information about the upcoming GTA V technology, in particular, how it is able to truly render all buildings you can see without a draw distance cap or any faking.

Since I will soon be prototyping a big city environment, I wanted some advice on this topic. We're talking about a really big city, with simple geometry but fully lit and shadowed. My doubt comes in particular to the projection matrix, which imposes a maximum draw distance (the zFar parameter).

Now, at the same time, I read everywhere that zFar should be as small as possible for better rendering results, in particular related to depth buffer issues etc, because of the floating point issues.

So, assuming my computer can render this big city in a stable framerate, how should I approach the problem of rendering parts of the city which I can see REALLY far away, fully lit and shadowed? Shadow maps also seem to have problems with low depth buffer precision..

Thanks

Default Z buffer is impractical for huge distances because it wastes A LOT of prescision for what is very close to the camera. A tiny increase in zNear kills prescision for distant objects.

Logarithmic Z buffer solves this problem by offering a more sensible distribution of prescision. It ensures there is enough prescision at almost any distance (at least enough to render a GTA city without resorting to rendering different parts or world with different Z buffers). There is too much details about implementing logarithmic Z to discuss here but I find this article great. The best trick from the article: if you are using Direct3D you can simply swap zNear and zFar in the code and you get an almost logarithmic z buffer!

Also, it is possible to render geometry closer than zNear and farther than zFar by enabling Depth Clamp but of course z buffer becomes useless outside of the frustum.

There's a few thing:

• Determine a good far and near clip.
• A smooth Level of Detail system, using simplified models at distance too reduce detailed z-fighting.
• Combining camera outputs
• Tesselation

Combining camera outputs is used by FPS games as a solution too the lack of precision you get from needing a near clip very close to the camera (e.g. to see the gun) and the need to see very far (e.g being able to see a mountain). So what you can do is to render the stuff that need to be close and detailed first and then the more distant surrounding. Combine the two images and there you go.

Then it comes to zFar and zNear their values does not really matter. It's the difference between them that decides the precision when comes to depth testing. You only got a few bytes to save the depth. Bad precision results in a lot of z-fighting and thats's usually bad thing.

• That camera output combination thing might be exactly the right answer to my question. It is the only approach that actually gets around depth precision issues all the way and allow "infinitely" far away geometry. Thanks. Any good reading on the topic you would recommend? Aug 17, 2013 at 16:00
• No unfortunately, I can only recommend a google search Aug 17, 2013 at 18:05

As a simple aproach:

You may perform a first render pass, with only far/low-polygon building. In this pass, you may use a small scale which allow a correct zBuffer accuracy.

In the second render pass, you delete the zBuffer and you render only near high-polygon objects with a higher scale.

• This only works properly in a forward renderer.
– Tara
Dec 3, 2015 at 3:29