Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Rendering terrain with low camera FOV results in gigantic performance loss

Discussion in 'General Graphics' started by Fewes, Mar 29, 2021.

  1. Fewes

    Fewes

    Joined:
    Jul 1, 2014
    Posts:
    256
    Hi there!

    In the process of optimizing CPU time for my flight game, I noticed a huge performance loss in the terrain rendering system when rendering a camera with a low FOV. Here's a snapshot of the profiler with my camera FOV set to 50°:

    terrain90fov.png

    Nothing strange here, the game is running pretty fast. Now let's drop the camera FOV to 5°:

    terrain5fov.png

    Yikes. Taking a look at the timeline view we can see that it is indeed the terrain that is the culprit, in particular it seems to be the culling pass that is the problem:

    terraintimeline.png

    My terrain setup uses 3x3 terrain tiles with 4k heightmaps which granted, is a lot of data, but this performance loss just seems crazy to me, especially since it is running so smoothly on higher FOVs.

    This seems to be caused by the way terrain geometry is constructed on the CPU before rendering, which is influenced by the Pixel Error parameter (I can regain a lot of performance by simply increasing this value alongside the camera FOV). I suspect this parameter is meant to be used as an intuitive way of controlling terrain quality, but just like the LOD Group component it scales terribly to special cases like rendering with a very low FOV and can be very difficult to tweak to get a consistent result.

    I'm not making this thread to report a bug, rather I'd like to suggest adding an optional, alternative culling mode to the terrain system that is based on distance to camera instead of view size.
    The pixel error parameter results in wildly inconsistent performance on different screen and camera setups, whereas a distance-based system would perform the same amount of CPU work no matter what. The developer can then decide themselves if terrain really should be rendered at a higher quality when the camera FOV is low, which is a much easier task than trying to rein in the effects of the pixel error parameter.
     
    Last edited: Mar 29, 2021
    wlad_s likes this.