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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Updates to the heightmap from SetHeights and SyncHeightmap for terrain

Discussion in 'World Building' started by crysicle, Oct 10, 2019.

  1. crysicle

    crysicle

    Joined:
    Oct 24, 2018
    Posts:
    95
    Hello, while developing tools for the terrain i noticed that SyncHeightmap() is much faster than SetHeights() when manipulating great amounts of heightmap data, however, it takes a big performance hit because it's waiting on the GPU. I also noticed that while calling SyncHeightmaps there's only 1 additional function which takes a performance hit and is visible inside the profiler - "Terrain.RecomputeInvalidPatches". Is this function just updating the heightmap information on the CPU with new heights collected from the GPU? If this is the case, how come SetHeights() is taking magnitudes longer to process compared to the former function? Is it because the former function is not sending any data back to the GPU while SetHeights() does? If that's the case, could the terrain API be extended for more versatile use for heightmap updates, which would allow to update the terrain heightmaps specifically for terrain collider only?

    With 2019.1 "CopyActiveRenderTextureToHeightmap" got introduced which allows to update the heightmap on the GPU without updating it on the CPU. A vice versa approach would also be great, giving full control on what goes on with the terrain collider on the CPU side.
     
  2. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    500
    I really hope we'll get an AsyncSyncHeightmap sometime. Seems like a small fix...