Search Unity

wow, terrain projection is super fast

Discussion in 'World Building' started by Rowlan, Nov 14, 2020.

  1. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    I thought I'd try terrain blending for a change with the terrain tools api. I have to say, I'm amazed, that stuff is super fast :eek:

    Here's a custom model projected directly on the terrain. The terrain is generated on-the-fly:



    In case anyone wants the code for that, just let me know.
     
    Last edited: Nov 15, 2020
    TerraUnity, GCatz, mgear and 2 others like this.
  2. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    I enhanced it a bit. Now it's non-destructive blending, ie the original terrain is saved and the projected one is blended with it. The model is just a simple ring:

     
    wyattt_ likes this.
  3. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    This is fun. I added blend modes, here's exclusive blend mode, i. e. the blended mesh takes precedence:



    Skull Island :D

     
  4. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    I stumbled upon this project yesterday and had an hour to kill, so I added direct projection to it. I probably should put it on github so that one of you guys can continue working on it if you're interested to do so:

     
    mariandev and mgear like this.
  5. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    Toyed around with it some more, added MicroSplat quickly with a Tea Pot:



    and then Procedural Texturing, just some random textures that should change depending on steepness, here's using a Gear as model:

     
    Last edited: Jun 26, 2021
    Voronoi and adamgolden like this.
  6. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
  7. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    I was in the train and had an hour to kill, so I gave this a quick try. The idea: flatten the terrain for a collection of houses, i. e. create a settlement. Aso allow dragging that collection of houses around. Quick prototype of course uses only cubes, but the mesh doesn't really matter.

    The algorithm:

    * create empty gameobject as collection
    * add houses (ie cubes in my case and a sphere for demo purposes) to that collection
    * put all extents of the bounds of those meshes into a list
    * create convex hull (or concave hull) of that list, but using the minimum y coordinate of all points for the final positions
    * resize the shape of the convex hull to create a little bit of boundary
    * triangulate the convex hull and create a polygon
    * project the polygon on the terrain

    Works quite well with this initial test:

    terrainalign.gif

    Should of course update while you drag around. There's lots of free examples for convex hull calculation and triangulation, so the only thing to do was bringing it all together into a class.

    One might want to keep the shape of the convex hull and manipulate it a bit. I guess it would be beneficial then to use the Splines package that Unity released this week for further manipulation. I only drew the light green debug line here, i. e. it's a simple polygon. Waiting for the preview version of the Splines, but combining it all with a closed Spline like I tried yesterday with the experimental version will be fun :)

    triangulator.gif
     
    Last edited: Oct 31, 2021
    wyattt_ and TerraUnity like this.
  8. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,251
    Thanks for these great contributions, excited to try this one out soon. Do you think it is also usable for meshes like roads or the Bridge tool is better for that? Can it be adopted to change texture at flattened areas too?
     
    yethumyat7201994 likes this.
  9. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    It really depends on the use case. The experimental Spline package has e. g. a road example. I'd use that to project the road on the terrain. This way the spline is reusable whereas the Bridge tool is not. Both have their advantages and disadvantages.

    Btw here's more info about the Splines:

    https://forum.unity.com/threads/at-...unity-add-splines.1067309/page-2#post-7614436

    But I'd wait until the preview version is out which is supposed to be soon. This will be huge. Also, Unity is very secretive about the Environment System. I guess we'll hear more about that once the 2022 roadmap is made public.
     
  10. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,251
    I see, I think splines in this case is winner! Can terrain projection and align be used to also change texture for those areas? because that would make this a complete solution for the most cases.

    Thanks for the link, just had a few minutes with it, so it's a good candidate for this thread of yours: https://forum.unity.com/threads/adjust-terrain-along-a-spline.929658/

    Environment System seems cool but they said it has nothing to do with the current terrain system! So what happens to all previous implementations on terrain system and its API! Do we have to learn a new feature again from scratch with new API?
     
  11. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,267
    Yes, you can change the splatmap as well. It's just another texture.

    I guess we'll see. They might as well combine it with virtual texturing. I hope there's an announcement soon.
     
    TerraUnity likes this.