Search Unity

New terrain system

Discussion in 'Works In Progress - Archive' started by pawfessor-fluff, Feb 7, 2016.

  1. Epitaque

    Epitaque

    Joined:
    Jul 28, 2015
    Posts:
    8
    1. Can you be a bit more specific on how you accomplish texture blending? You mentioned you store two material IDs and their intensities in each voxel. How do you get this information to the fragment shader, 3D textures? After you relay this information about material IDs to the fragment shader, how is the blending done? Some floats would have to be interpolated at each vertex (unless I'm missing something), but I'm not sure how one would know which interpolated float represents which material. Also, how many times do you sample textures in the fragment shader? Triplanar texturing is already expensive with one texture, but you're blending up to 6(?) textures per fragment, so does that mean you're sampling textures 18 times in the fragment shader?
    2. How did you stitch chunks in your LOD videos? There's a solution to this in dual contouring meshes, where you collect all the nodes contributing to the seam, create a new octree, then run the dual contouring algorithm on that octree. This approach creates a dependency between chunks and would reduce performance.
     
    Last edited: Mar 4, 2017
  2. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    Hi, happy to answer technical questions, I spend a lot of time trying to find the best approach :)

    1. I found that duplicating vertices gives the best performance. This means that for rendering each vertex of the triangle has the same 6 materials in the same order. There's a bit of data duplication but I'm managing it with crazy packing: a vertex encodes its position, normal, 6 material IDs, 6 intensities, and LOD+1 position, normal and 6 intensities in just its coordinates and two sets of float4 UVs. (The LOD+1 values are needed for the smooth geometry transition). I found this gives better framerates than a similar Unity terrain. Vertex duplication is needed for SM3, I expect that a DX11 shader will be much faster.
    Of course many triangles will have less than 6 materials so they can sample fewer times. (This is spatially coherent on the screen so conditionals are helping here).
    For triplanar texturing I'm not sampling 3 times. In the demos I'm choosing a projection for each pixel which creates a sharp separation between projections but as you can see it's not noticeable unless you look for it. But I intend to remove this sharp transition by using a projection per vertex and taking advantage of the heighmap blending I'm already doing. The projection can be added to the material ID so a triangle could blend "material A projected from the top" from one vertex and "material B projected from the side" from another vertex.

    2. My chunks do reach into their neighbours when building their border. However unlike both Unity's terrain (and I believe Nick's terrain as well) I'm not creating borders across different LODs. A chunk at LOD(n) only has borders with its neighbours at LOD(n). However the chunk also maintains a second set of positions/normals/materials (as mentioned above) at LOD(n+1). This allows a LOD(n) chunk to smoothly transform into LOD(n+1) as you move away from it, which includes its borders to other LOD(n+1) chunks. When you are far enough the LOD(n) chunk gets replaced by the real LOD(n+1), without any pop because they look identical.
    A big advantage of doing it like this is that I'm avoiding rebuilding mesh borders when showing/hiding chunks. Borders are only created/updated during editing.
    A disadvantage is that coarser LODs need to preserve more detail from finer LODs, it's not good enough to just cut voxel resolution in half. This is the part I'm working on at the moment.
     
    Arkade, Venryx and Epitaque like this.
  3. Twoonebe

    Twoonebe

    Joined:
    Mar 30, 2013
    Posts:
    174
    Something news about your Terrain asset ?
     
  4. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,374
    Does this support planet wide terrain streaming a-la google earth?
     
  5. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    @Elecman: Yes, this is the intention, streaming or generating on the fly.
     
  6. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    After a long pause here's finally an update worth sharing. To make up for it, this time I'm also including a playable demo.
    http://176.61.82.6/demo/demo.zip



    It includes too many bugfixes and improvements to keep track of, with some of the main ones being:
    * quadric mesh simplification
    * import from Unity terrain
    * improved grow/shrink brush
    * material blending between projections
    * just-in-time mesh collider
    * many fixes, both for editor and runtime

    I expect this will be the last update before a commercial version. I will be working on improving the quality of brush intersections (eg spheres still need work), a large scale raise/lower terrain brush, and testing for various platforms and render options. There is plenty of room for performance improvements as well.
     
    Magiichan, Peter77, PeterB and 14 others like this.
  7. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Argh, you horrible tempter/temptress! You dangle these amazing morsels before our paws like a laser pointer but then ”no, you cannot have it”. I'm fully expecting your next post will be ”begggggg... and now roll-over!” Programmers are cats. Haven't you heard, we will not herd! We don't perform tricks at the whims of our human slaves for tasty treats like lesser cre... Oh p please please please please please. Waaaaant.
     
    pawfessor-fluff likes this.
  8. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    In the demo I could not seem to click and have a single action applied. It seemed to register several clicks and moved a bit after each click. It would be nice to have an option that limits one action per click.
     
  9. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
    the last update is really amazing!
    @pawfessor-fluff will you consider an option to create a regular mesh (instead of terrain) then manipulate it in editor the same way it interacts with terrain???
    am thinking about this because these amazing structures are built on terrain, so in case i want to shift building somewhere, it will be headache to rebuild the structure again! also it will be awesome if there is some sort of stamps which enable be in one click to create a shape.. like box or terrain bridge or something..
     
    Arkade likes this.
  10. Farelle

    Farelle

    Joined:
    Feb 20, 2015
    Posts:
    504
    this looks amazing :O
     
  11. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    Thanks!
    Yes, I was thinking about the same thing, creating small "terrains" and exporting them as prefabs.
    Also for the terrain itself I'm thinking a copy/paste brush should also be useful.
    I have a few bugfixes for the demo so I'll post an update.
     
  12. mangax

    mangax

    Joined:
    Jul 17, 2013
    Posts:
    336
  13. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    Any updates?
     
    Arkade, mangax and StaffanEk like this.
  14. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    Sorry about the long silence folks, I have been working on it though and it's almost done. I promise I'll give you an update soon.
     
  15. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    I managed to crash the demo by just painting a texture onto the terrain. I attached the output log. (the application used about 4gb of ram (i have 10) before it crashed - as i read something about it being out of memory)
     

    Attached Files:

  16. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    Thanks for reporting, I'll look into this.
     
  17. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    So this should just work the same on macOS, being just SM 3.0?
     
  18. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    Yes, it does. I've also tested it on iOS and Android.
     
    orb likes this.
  19. invadererik

    invadererik

    Joined:
    Oct 31, 2010
    Posts:
    148
    Hey need more testers ?
     
  20. CoughE

    CoughE

    Joined:
    Oct 26, 2015
    Posts:
    39
    Any update on the terrain system? Very interested in using it for my game :)
     
    MCrafterzz likes this.
  21. MCrafterzz

    MCrafterzz

    Joined:
    Jun 3, 2017
    Posts:
    354
    Also does it support sharp edges for a low poly look?
     
  22. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    Yes, it does. Sorry I'm still hard at work trying to fix final things. I did make an alpha version available to a few people, please send me a private message if you're interested.
     
    CommunityUS likes this.
  23. Mr_Albert

    Mr_Albert

    Joined:
    Apr 28, 2017
    Posts:
    25
    Hi!

    @pawfessor-fluff ...


    sorry if I ask you two questions but it's interesting what you're doing

    is it part of unity's beta?
    do you have a twitter account where you can follow in this work?

    thank you
     
  24. ilesonen

    ilesonen

    Joined:
    Sep 11, 2012
    Posts:
    49
    This is looking really interesting! Tried to download your playable demo but link gives 404 error?
     
  25. pawfessor-fluff

    pawfessor-fluff

    Joined:
    Feb 7, 2016
    Posts:
    41
    @Mr_Albert: no, it's not part of Unity, it will be a standalone component. There's no twitter for it, I'm adding updates to this thread.
    @ilesonen: thanks for letting me know, I will update the demo to the latest code and post a working link.
     
    Magiichan and mangax like this.