Search Unity

New terrain runtime tools

Discussion in 'World Building' started by pointcache, Oct 10, 2018.

  1. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    Can i work with API on runtime? I.e. make a gui for brushes and use same terrain editing functionality for runtime editor?
     
  2. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    I think you would have to handle multi terrain editing yourself but the shaders you can download and edit.

    The heightmap is now a rendertexture you can edit with a shader pass or compute shader.

    I did a small test and added rotate functionality to the paint and stamp brushes. seems easy to customize.
     
  3. ChrisTchou

    ChrisTchou

    Unity Technologies

    Joined:
    Apr 26, 2017
    Posts:
    74
    Yes, a good part of the new API is available at runtime, for the purpose of doing live editing. Specifically the PaintContext seamless multi-terrain editing class is available at runtime. Note that editing terrain can be a fairly expensive operation, perf wise, because it has to update physics/AI/visibility, so take that into consideration.
     
    pointcache likes this.
  4. ChrisTchou

    ChrisTchou

    Unity Technologies

    Joined:
    Apr 26, 2017
    Posts:
    74
    Also FYI -- if you are using the new Terrain API -- an update to the API is coming out in beta 6, so any custom tools you write in beta 5 or before may need to be fixed up.
     
    DougRichardson likes this.
  5. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    If you are still doing API changes... NativeArray access to the heightmap copy the terrain has on the CPU would be great. The same way you can access a Texture2D raw data with a NativeArray.

    I want to sample the terrain heights in Jobs and now I need to get it with the GetHeights API and that makes GC and is slow. Reading this data direct would make everything much faster.

    Lennart
     
    hippocoder likes this.
  6. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    579
    This is awesome. Performance is not a concern to me since its for map editor, so its still not realtime. Just has to be in game.
     
  7. ChrisTchou

    ChrisTchou

    Unity Technologies

    Joined:
    Apr 26, 2017
    Posts:
    74
    I'll add this to the list.