Search Unity

Question Is there a hard maximum far/near clip plane ratio?

Discussion in 'General Graphics' started by kring789, Dec 22, 2022.

  1. kring789

    kring789

    Joined:
    May 5, 2022
    Posts:
    1
    Hi,

    My team and I are developing Cesium for Unity:
    https://github.com/CesiumGS/cesium-unity

    It makes it easy to render large-scale geospatial datasets in Unity, up to including the entire Earth. As you can imagine, this involves some very large view distances, such as when viewing the whole planet from space. And it's also possible to have something up close to the camera (a satellite, perhaps), while also having something very far away (perhaps the planet itself). This sort of application always poses a challenge for depth buffer precision, and the graphics team at Cesium has been thinking, writing, and presenting on this subject for many years.

    To summarize very briefly, we have generally found the following depth buffer solutions to be adequate for the needs of most applications, in order of preference:

    1. A 32-bit reverse floating-point depth buffer
    2. A logarithmic 24-bit depth buffer
    3. When all else fails, render with multiple frustums in a far-to-near order

    As virtually all modern hardware and graphics APIs these days support solution (1) at this point, we expected that would be Unity's approach. But we're running into an odd problem.

    The problem is that Unity seems to simply forbid us from setting the near and far clip distances such that the far/near ratio is greater than ~100,000. Or, to be precise, it lets us set the values to whatever we want, but then effectively clamps the far distance to be no more than 100,000 times the near distance. A reverse floating point depth buffer should be able to support a much greater range than this without major artifacts, so we're not sure why there's such an arbitrary limit.

    Is this expected, and is there any known workaround? In case it matters, most of our tests have been in Windows (D3D11) with URP and Unity 2021.3.

    Thanks for any insights,
    Kevin
     
    jdh5259 likes this.