Search Unity

Most efficient way to patch terrain data

Discussion in 'World Building' started by snacktime, Jan 26, 2019.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    I think I have the answer but just in case there is something I don't know.

    Our game lets players modify height and alpha maps, and there are a lot of terrains in the game. We give every player a decent sized part of a terrain to customize and build on.

    The best approach I've found to date is save delta's of the alpha/height maps to the server in a compressed format. Push those to the client when they enter the scene, and also saving those to disk so next time they only download new delta's. I update the entire terrain vs just the part that changed. It's a bigger but acceptable time, and it solves the problem of accumulated delta's. Easy to merge all of them if you always update the entire terrain.

    Ideally I'd like to patch the terrain data. With the above approach a single delta means that terrain has to be forever updated on scene load. Not a huge issue but if there is a better way it would be nice.
     
  2. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    Are you asking how should you update a small part of the terrain height without updating the entire terrain? Can't tell if this is a data question or a terrain-specific question
     
  3. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    It's not about how to use the api's. It's about what is the most efficient way to distribute/load incremental changes over time to multiple clients.
     
  4. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    Oooh I see! One option could be to cache the data on the client side, using whatever format you wish (JSON, for example), perhaps with some sort of id (which could be some sort of server-time, or just a number of some sort). This ID could also be stored on the server. Then, when the scene loads up, check if this ID matches with the current terrain chunk ID on the server. If not, request the new deltas or whatever :)

    Essentially, each "terrain patch" has an ID