Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Terrain Composer2 a next generation GPU powered terrain tool.

Discussion in 'Assets and Asset Store' started by eagle555, Sep 16, 2012.

  1. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Hey Everyone,

    I'm making good progress with the new MCS update which will have a free extension called `MCS Caves & Overhangs`, basically has the feature to remove overlapping geometry to optimize rocks to the max. There's other use cases for it but this is the most obvious one I can think of.

    I opened a new thread for it here and made a video showcasing it:
    https://forum.unity.com/threads/mcs-caves-overhangs-will-release-soon.659845/

    MCS Caves & Overhangs4.JPG
     
    kepesh likes this.
  2. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Yes it is possible to generate trees, grass and objects on existing terrain without touching the splat and height. Only I need to make a way for the `Terrain Area` to detect the terrains if you drag and drop them as children. We have to release another Drone update this week with a new arena, but right after I will implement this.
     
    gecko likes this.
  3. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,187
    Awesome, thank you!
     
  4. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    By the way does http://www.terraincomposer.com/ work for you again? It works fine on my side. Anybody else has the issue that the site is not working?
     
  5. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,187
    Nope, still not:

    This site can’t be reached
    www.terraincomposer.com’s server IP address could not be found.

    DNS_PROBE_FINISHED_NXDOMAIN
     
  6. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    That's really odd, where are you located?
     
  7. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,187
    Minnesota, US. (I don't think our state government has started blocking dangerous websites :)
     
  8. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,205
    Works fine for me and also on tuesday when I checked. Tried to access from USA aswell, no change
     
  9. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,440
    Works for me, in AZ.
     
  10. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    199
    works for me in uk 12th apr 02:26 BST
     
  11. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,187
    Loads on my phone using cell signal...so I guess my IP is blocked? Or something else, not sure what it might be. But not a general problem obviously.
     
  12. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Might be that your firewall is blocking the website for some reason.
     
  13. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    471
    @eagle555 Please, I really need to be able to flatten terrain under buildings. I have struggled again and again with the "Manual Placement" function, and it just does not work. The video showing it working is NOT a tutorial! 1 picture in the dox with some confusing text is NOT a tutorial. Can you PLEASE create a step-by-step guide showing what needs to be setup on the capsule to make it behave in the manner that it does in the video. HOW is it set not to show the mesh renderer in the scene mode? I attached the TC_Auto Generate script to it, and it does nothing to displace the terrain. If I click on Instant Generate, I cannot even move it in real-time. If I disable the mesh renderer and turn off instant gen, I get the usual green collider shape and no change to the terrain. What gives?
     
  14. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    The video is indeed not a tutorial but it shows what can be done with it. The key to understand here is that the detection is done with a camera, so the camera needs to `see` the object with the collision mask.

    In the first image I show how to hide the mesh from the Scene camera:
    http://www.terraincomposer.com/wp-content/uploads/2016/07/CollisionNode.jpg
    http://www.terraincomposer.com/wp-content/uploads/2016/07/CollisionNode2.jpg

    It needs some basic understanding how Unity layers work with cameras:
    https://docs.unity3d.com/Manual/Layers.html

    Can you show screenshots how you set it up on your side? I can see then what is going wrong and will then make it more clear in the documentation.
     
    Last edited: Apr 16, 2019
  15. jamesnw

    jamesnw

    Joined:
    Mar 23, 2013
    Posts:
    42
    Hi, I love TC2! ;) It works with InfiniGrass also, since that uses the splats, but it was VERY slow on a terrain of 4096x4096 (had to force terminate Unity as it was taking too long). TC2 applies the hights, splats, grass, and trees in seconds. :) I just wish there were more trees like there are grass, but not a big deal of course. My only question now is, how can I detect nearby grass/trees and delete them? I want to delete them as the user drops buildings down on the terrain (in script obviously), thanks.
     
  16. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Thanks, I'm glad you like it :) Feel free to make a review...

    Does the 4k terrain hang Unity? Or does it finish at some point? Think it's a bug.

    You can change the tree / object resolution in the main output node in the Inspector:
    upload_2019-4-20_6-42-40.png

    You can use masks (blue nodes) to delete trees / grass:
    http://www.terraincomposer.com/wp-content/uploads/2016/06/TC2_QuickGUIGuide2.jpg
    http://www.terraincomposer.com/wp-content/uploads/2016/06/SelectLayer.jpg

    Or use the manual object placement, with a stretched capsule mesh under your objects that you spawn:
    http://www.terraincomposer.com/terraincomposer2-documentation/#manual-object-placement
     
  17. jamesnw

    jamesnw

    Joined:
    Mar 23, 2013
    Posts:
    42
    I meant InfiniGrass was way to slow, TC2 was done in seconds, no problem. ;)

    I don't think you got my point. I need to delete grass/trees in a selected area (where a building will be placed - perhaps a hit point and radius) at runtime by *Script*, not in the editor, thanks.
     
  18. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    So you want to use TC2 at runtime to regenerate the trees and grass? But then how about the infiniGrass? It would need to be converted again I think.
     
    Last edited: Apr 20, 2019
  19. jamesnw

    jamesnw

    Joined:
    Mar 23, 2013
    Posts:
    42
    You seem to keep missing the key word "delete" in both my posts - I want to DELETE the trees or grass in a give radius when placing objects down on a terrain - and yes, at runtime, hence the words " runtime by *Script*" ;), thanks.
     
  20. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Yes I know that you mean to delete the trees and grass, but for TC2 means it needs to regenerate with parts excluded. You can do this with the manual object placement technique:
    http://www.terraincomposer.com/terraincomposer2-documentation/#manual-object-placement

    So you need to put a mask on the top tree and grass output:
    upload_2019-4-20_20-7-27.png

    This uses a camera from below the terrain to detect (see) any mesh (see the capture in the preview image). So you can place a flat sphere / capsule / cube, etc where you want to remove trees and grass. You can use layermask for the camera to only see the meshes you want. Then can give TC2 command to generate the trees and grass. Here's an example how to generate from code:

    Code (CSharp):
    1. public class TC2Runtime : MonoBehaviour
    2. {
    3.     public bool generate;
    4.  
    5.     // For testing in the Inspector
    6.     void Update()
    7.     {
    8.         if (generate)
    9.         {
    10.             generate = false;
    11.             Generate();
    12.         }
    13.     }
    14.  
    15.     private void Start()
    16.     {
    17.         // Need to do this once for it to work, will remove the need for regenerating the height
    18.         TC_Generate.instance.Generate(true, TC.heightOutput);
    19.     }
    20.  
    21.     void Generate()
    22.     {
    23.         TC_Generate.instance.Generate(true, TC.grassOutput);
    24.         TC_Generate.instance.Generate(true, TC.treeOutput);
    25.     }
    26. }
    After generating you can disable the sphere. I will update for it not needed to regenerate the heightmap, as it's needed in the other outputs to be able to read height / angle from the terrain, but I made a scan option for this, that somehow doesn't work in playmode. Also sometimes it leaves a tree somehow, on the grass it works fine. Will fix all in next update.

    If you need more help with it let me know.
     
    hopeful likes this.
  21. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,205
    Might add that once Nathaniel merges the partial generation, this will look different and include the bounds/size of the object you moved which will make it update way faster. Can change the script accordingly after the update.
     
  22. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Ah yes, will integrate all your code in the next update for this.
     
  23. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,187
    really looking forward to this -- do you think you'll be able to do it soon?
     
  24. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Yes I will work on it soon, it's my next priority.
     
    gecko likes this.
  25. jamesnw

    jamesnw

    Joined:
    Mar 23, 2013
    Posts:
    42
    Thanks for the tip, but seems to be kludgy to have to use a camera just for this. Is there no way for me to just find out the grass and trees in a radius and delete them?

    Wouldn't it be easier to simply support masking by objects instead of needing a camera? All it would take is getting all objects from a given layer when placing objects using their colliders as null-zones (during the grass/tree placement process). Or better yet, in my specific case, create a method that accepts an array of positions and colliders like "RemoveTrees/Grass/Objects(GameObject[] areasToRemoveFrom)", and just pull the position and collider to delete accordingly?
     
  26. jamesnw

    jamesnw

    Joined:
    Mar 23, 2013
    Posts:
    42
    Ha, got it! :) The mask works find without a camera. I'm not sure why you mentioned to put in a camera...? I simply added a sphere, put it into a layer, assigned the layer to the collision node, set the node to "multiply", hit generate, and the grass was all gone in that area! So now all I have to do is ray cast, place a sphere, then regenerate grass and trees at runtime. Better yet, I'll just have a layer for the buildings, so they will be excluded automatically.

    upload_2019-4-21_6-52-22.png

    Thanks. :)
     
    Last edited: Apr 21, 2019
  27. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    No I mean internally it uses a camera, and takes a snapshot only 1 time when it generates the mask. Because everything is calculated on the GPU it makes things a bit more tricky (there's no out of the box functionality for raycasting on colliders on the GPU). But actually the camera is more accurate. Can even be used with tessellation.
     
    Last edited: Apr 21, 2019
  28. shwa

    shwa

    Joined:
    Apr 9, 2012
    Posts:
    458
    Hi,
    Does this now work on mac os?
    I'm on high sierra v10.13.4.
    If yes, what unity version should i be using?
    thx,
     
  29. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Yes it should work with Mac and it needs Metal for it which is needed for compute shaders to work. Should work with +U2018.1 I think.
     
  30. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    ftejada likes this.
  31. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Hi I made the terrain scan feature for you. Sorry that it took a bit longer due to the MCS Caves & Overhangs release.

    Steps:
    1). Make sure you have a backup of your terrain data files in the project window. Can export them as a Unity Package when right clicking on them (don't include dependencies).
    upload_2019-4-27_8-30-9.png
    2). Make sure you disable the outputs like height and splat you don't want to overwrite in the TC2 window.
    3). Add your terrains as children in this order, so from left to right and up with world x axis aligned as in the screenshot.
    4). Click the "Scan for Terrains" button.
    5). You're good to go.

    upload_2019-4-27_8-25-23.png

    Let me know if it works...

    Nathaniel
     

    Attached Files:

    syscrusher, gecko and hopeful like this.
  32. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,187
    Thank you SO much, this is a HUGE help. I really appreciate it!!
     
    eagle555 likes this.
  33. bgrz

    bgrz

    Joined:
    Mar 22, 2015
    Posts:
    58
    Hey @eagle555, I'm getting the exact same error, on Unity 2018.3.14f1 with TC2.63 from Asset Store. We're in the process of upgrading our existing project from 2018.2 so if you have a hotfix for this I'd gladly accept it ASAP.

    It's reproducible in an empty project, and in ExampleMountainVillage if heightmap resolution is increased to 4097.
     
  34. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Oki will take a look today if I can fix it.
     
    bgrz likes this.
  35. gozdagb

    gozdagb

    Joined:
    Feb 23, 2014
    Posts:
    71
    Hey
    why when i export from WM raw file as .r16 and i set to resolution of 2k, TC make it 512?
     
  36. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    TC doesn't make it 512, it will keep the resolution as is and supports up to 16k raw file. It spreads the stamp over the terrains, so it depends on how many terrains and which heightmap resolution they have. The heightmap resolution of the terrains you can change in TerrainArea GameObject -> Inspector -> Resolutions tab. For realtime editing it's best to keep heightmap and detail (grass) resolutions low and when done put them higher. The default terrain resolution is 512, as that gives good realtime editing speed.
     
  37. gozdagb

    gozdagb

    Joined:
    Feb 23, 2014
    Posts:
    71
    Resolution tab, pfff... thanks :)
     
  38. gozdagb

    gozdagb

    Joined:
    Feb 23, 2014
    Posts:
    71
    Hi
    1. Is it possible to use other objects than capsules to modify hmap?
    2. Is it possible to use 2 different objects at the same time, where 1 modifies hmap and 2 only splat map?
    3. Will there ever be a erosion node? if yes then:
    3a. There will be possible to get result of this node where is flow/wear/depo map?

    thanks
     
  39. bgrz

    bgrz

    Joined:
    Mar 22, 2015
    Posts:
    58
    Found the root cause: TC_Compute.bufferLength, being float, gets the wrong value when assigned a value of 4097², 16785408 instead of the correct value 16785409.
     
  40. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Ah yes good find ;) I was just looking into it as something came up. It should be an int instead. Here's the fix for it.
     

    Attached Files:

    bgrz likes this.
  41. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    1). Yes you can use any mesh shape for it. Internally it uses a camera, so whatever a camera can `see` can be used.
    2). Yes you can set this up with Layers and on the camera setting the LayerMask (In case of TC2 the layerMask is in the node). The same way e.g. when you have 2 cameras and show objects on one camera and hide on the other with LayerMask. More info about it in the Unity docs:
    https://docs.unity3d.com/560/Documentation/Manual/class-TagManager.html
    3). I'm not sure, not in the near future. You can get erosion looking results with the build in Jordan and Swiss noise. You can see the results with loading the presets in the node. Also you can use convexity input to get a bit of a flow-map result.
     
  42. voc007

    voc007

    Joined:
    Nov 18, 2012
    Posts:
    7
    Capture.PNG I have two issues:

    1) How can I Import raw image into the specific terrain, example 3x3 terrain, I want to import into X:2, y:3. It always imports right in the middle and I have to move it to that terrain sector.

    2) when I try the scene samples, the capsules are white and thin, they don't seem to work.

    Currently using 2018.3.10f1
     
    Last edited: May 9, 2019
  43. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    1). That's a good question. Yes you have to move and set the size in the Node Inspector. Today I will add terrain buttons to the Node Inspector like in the TerrainArea GameObject. If you click on it TC2 will automatically position and scale the stamp to fit the terrain. Will also make a button to fit and stretch it over all terrain. But it's still more easier to not cut a heightmap in chunks and use one heightmap in TC2 as it's supports up to 16k raw images.

    2). The capsules are supposed to flatten the terrain. Can you show a screenshot of the TC2 window with the collision detection layer visible?
     
  44. kepesh

    kepesh

    Joined:
    Dec 29, 2017
    Posts:
    92
    Is there a way to make collision masks work with objects that use a LOD group?
     
  45. voc007

    voc007

    Joined:
    Nov 18, 2012
    Posts:
    7
    Capture3.JPG here is the screenshot of the collision layers. Capture.JPG

    seems like it is missing tc_autogenerate and capsule collison. I tried to add components, they just disappear.
     
    Last edited: May 10, 2019
  46. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,096
    I've just recently started using the manual object placement, and I'd like to suggest updating the documentation to make it very clear that the object detection uses a camera and not collider raycasting.

    I watched your tutorial multiple times and read the manual multiple times, but still couldn't figure out why your example was correctly detecting the collision objects, but my own prefabs in the same scene were not being detected. The fact that the TC2 node uses the word "collision" makes it seem as if it's doing the very common physics raycast to detect the objects. I wanted to flatten some areas without a building or other visual object, so I created some box colliders. Only after hours of experimentation and some forehead-against-wall experiences did I finally realize what's actually going on here.

    Now that I know, it's no problem that it works that way, but if the docs had made this more apparent it would have saved me some time. :)

    As an aside, I think it might be useful to add a true *collider* detection option because empty colliders -- placed on a physics layer that doesn't collide with players etc. -- would be useful to create gross-scale land deformations or flat areas without cluttering the scene edit with extra visible meshes or having to toggle layers on and off with cameras. I could also see this being useful to have TC2 generate terrain features such as a steep cliff to match box colliders that mark the boundaries of the playable area. Keep the camera detection you have, for all the reasons you explained above, but add the physics collider detection alongside it (or perhaps as an option setting for your collision mask node, which is really an object detection node and not a collision node).

    For what it's worth, I'm absolutely loving TC2. I hadn't used it for a while but am back into it lately. The UI redesign between TC1 and TC2 was a quantum leap forward.
     
  47. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Good point, will make that more clear. The reason it uses a camera instead is that it's not possible to use physics on the GPU. Also a camera is more accurate and even works with tessellation and it's a lot faster.

    I could do it on the CPU and then upload it to the GPU, but it would be a lot slower. Before I measured Unity can do about 1M raycasts per second (before U2018.3) on the main thread, maybe it got a bit faster now. But still if you would generate a 2048 x 2048 raycast node it's 4M rays, would take 2-4 seconds by itself. While with a camera you can do like 60 - 400 such nodes per second.
     
    syscrusher likes this.
  48. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    Probably they were culled by the LodGroup because of TC2 internal camera distance. I made an update where I set QualitySettings.LodBias to infinity before rendering the camera. So always Lod0 is used, which gives the most accurate results.

    Let me know if it works now...
     

    Attached Files:

  49. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,704
    The collision mask node works, but you can see the yellow nodes don't capture anything:
    upload_2019-5-11_8-24-46.png

    You need to use the same settings as the mask collision node, except put collision mode to `height`. You can delete the yellow node and duplicate the collision mask node with selecting it and `control + d`. Then drag and drop it where the yellow node was, and put collision mode to `height`.

    Let me know if you can get it to work...
     
  50. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    471
    Hmmm, just upgraded to 2018,4,0f.1 and get 4 errors. 2 in TerrainSerialization.cs (I added " || UNITY_2018_4" to the #if statement and they went away) and 2 in the TC_Terrain.cs. || UNITY_2018_4 doesn't fix those.

    "Assets\TerrainComposer2\Scripts\Terrain\TC_Terrain.cs(331,13): error CS0103: The name 'castShadows' does not exist in the current context"

    &

    "Assets\TerrainComposer2\Scripts\Terrain\TC_Terrain.cs(405,44): error CS1061: 'TCUnityTerrain' does not contain a definition for 'castShadows' and no accessible extension method 'castShadows' accepting a first argument of type 'TCUnityTerrain' could be found (are you missing a using directive or an assembly reference?)"

    Any ideas?
     
    syscrusher likes this.
unityunity