Advertisement

How to get really long draw distances?

Started by January 14, 2020 03:15 AM
12 comments, last by Hodgman 4 years, 7 months ago

It's worth defining what “really long” means in this context. Standing at sea level the horizon is about 5km away. The longest possible sight-line on earth (mountain-top to mountain-top) is about 500km.

The easiest approach to the appearance of a massive draw distance is to render two things: a mesh terrain up close, and any distant mountains baked into the skybox. With fairly simple LOD handling you can push the mesh terrain out to a few kilometres, and as long as the user isn't travelling at aircraft speeds, there won't be appreciable parallax with the backdrop.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

I worked on a game set in space a while ago. I needed what is essentially infinite view distance. For what it's worth, I was generating a sky box in real time by rendering distant objects on it. As the camera got close enough they would become meshes with lowres and increase in res as camera got closer. That worked for me.

Advertisement

https://www.gamedev.net/forums/topic/693404-reverse-depth-buffer/5362188/

^ To get good z-buffer precision and avoid z-fighting for long view distances, the easiest thing to do is just use a reversed-floating point depth buffer (where the far plane projects to 0.0 and the near plane projects to 1.0).

* Use a D32_FLOAT / R32_FLOAT depth resource (or DXGI_FORMAT_D32_FLOAT_S8X24_UINT if you need stencil too).

* When you create your projection matrix, swap the near/far values.
e.g. instead of Perspective(fov, aspect, near, far), use Perspective(fov, aspect, far, near).

* Change your depth test from D3D11_COMPARISON_LESS_EQUAL to D3D11_COMPARISON_GREATER_EQUAL.

* Clear your depth buffer to 0.0 instead of 1.0.

This topic is closed to new replies.

Advertisement