Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[uTerrains] Ultimate Terrains - Voxel terrain engine

Discussion in 'Assets and Asset Store' started by Amandin-E, Feb 4, 2016.

  1. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    5,571
    I was talking about the mapping, basically there is two type of mapping for making voxel planet:

    1. axis aligned voxel data

    2. surface aligned (which I was talking about)


    Ideally for planet you want surface aligned data, but as you can see sometimes the number of neighbor is not consistent, it's call a "pole"

    - The regular sphere has two poles up and down, which create a lot of pinching and distorted area size.
    - cube sphere have 8 poles in the corner of the cube, where a cells has 7 neighbor instead of 8, but area are more or less constant (with a special projection).
    - Icosahedron sphere has a lot of pole (12 I think) but some cells has 7 neighbor (call T-pole) and some other have 9 (call E-pole), but it also have the best conservation of area.
    - Also direction of cells direction are not consistent inside region delimited by pole, because of the 3d ness of the issue. Which mean you need to convert basis whenever you cross an edge of a region.

    Typically people go for the cube sphere as it's closer to flat coordinate and handle conversion at edge and corner, which are consistent across all faces.

    Basically for any terrain system to be compatible, they need some sort of hook to handle and stitch terrain from different region of a sphere and poles.

    It's a requirement for planet that are bigger than an asteroid.
     
    sharkapps likes this.
  2. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
    Many thanks, Still wrapping my head around the voxel value system :) Your new system seems very nice btw. And I personally care much more about UVs compared to the default shader but I understand it is not everyone's opinion.
     
  3. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @neoshaman
    OK I get it now. Ultimate Terrains handles only axis aligned voxels. So if you want a cubical style planet, you'll get something like in your first picture. If you go for smooth voxels, you can get something like my previous picture.

    @Ashkan_gc
    Note that UV cannot be properly set for such terrains because of verticals and overhangs. So in any case you won't be able to get good result with the standard terrain shader unless you make it triplanar mapping. You really need triplanar mapping.
     
  4. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Hi there,

    Just to let you know v2.1 is pending for review (by the asset store team).

    It includes bug fixes (voxel size!=1, operations save issue), the new tree system and the new GPU instanced details system.
     
  5. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    annnnnnnnd.... it's online! :)
     
  6. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
    Awesome, Will take it to a drive today
     
    Amandin-E likes this.
  7. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
    Doing some tests today I got into two isses. Again here is the code of my tunnel but horizontal this time
    Code (CSharp):
    1. public void Combine(float x, float y, float z, float[] values2D, float[] values3D, out float voxelValue, out VoxelType voxelType)
    2.     {
    3.  
    4.         if (Mathf.Abs(x) < 20 && Mathf.Abs(z) < 2000 && Mathf.Abs(y) < 20)
    5.             voxelValue = -1;    //y - height;
    6.         else
    7.             voxelValue = 1;
    8.  
    9.         float distance = 15 - Vector2.Distance(Vector2.zero, new Vector3(x, y));
    10.  
    11.         voxelValue = Mathf.Max(distance, voxelValue);
    12.  
    13.         voxelType = mainVoxelType;
    14.     }
    The issue is when I move (this is running in the flat terrain scene if settings are different in your different scenes) using shift and up arrow forward then until I am not too close to the tunnel entry point it doesn't generate meshes in my view forward , After a few generations , sometimes a cell in front of the cell in front of me is generated so between us there is distance and after moving forward for sometime again I have a long tunnel in front.

    Is there any bug or I should change settings to have a generation which is consistent.

    The other issue which is more of a question is, a friend of mine wants to use a voxel engine in unity but he needs WebGL support, Is there any chance you can support it. As far as I see the only issue is threads and the fact that on a single thread it will not be the same quality in terms of performance, but is it a possibility to have it if he wants to use your asset?
     
  8. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @Ashkan_gc
    Looks like your problem occurs because you move to fast compared to the terrain generation time and view distance. What are your settings about max level count and build distance?

    WebGL is not supported because of what you said and the amount of memory needed. Maybe your friend could make it work with minimal settings but I wouldn't recommend it.
     
  9. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
    I have no settings called build distance, lod count is set to 7, was 5
     
  10. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Sorry, build distance is called "draw size" in the inspector GUI. But if the LOD count is already 7, I doubt it will be better by increasing the draw size as it would make the terrain longer to generate.

    It's quite hard for me to figure out what is really happening with your terrain. Could you send me a video? And maybe a Unity package so I can load it on my PC? Also, just curious, what is your hardware (cpu, ram)?
     
  11. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
  12. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Thanks for this feedback, I could reproduce the problem.
    The problem comes from voxel values being "too far" from 0. Just adding
    Code (CSharp):
    1. voxelValue *= 1f/64f;
    at the end of your combiner fixes the issue.

    I know this is counter intuitive and I'm not satisfied with it. I should either not clamp voxel values between -1 and 1, or I should add a kind of "equalizer" in which you'd have to say "my voxel values are meaningful between -100 and 100" for example (instead of -1, 1). Of course, I need to do some tests to figure out which one is best. In the mean time, please just divide your voxel values to fix this.
     
  13. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
  14. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @Ashkan_gc @runevision
    I've found a clean way to solve the issues caused by voxel value clamping. In the next version, you won't have to divide your voxel values to get nice result. The engine will handle it properly ;)
     
  15. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
    Many thanks. By the way I'm ready to help in the docs, just let me know how can I start? Should I write a blog post on our own website? … We can also connect on skype to discuss more on how can I help
     
  16. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009

    That is great since dividing my voxels by 64 resulted in this from outside while the issue about view distance (mesh generation) was resolved

    upload_2018-6-15_17-33-4.png

    And yup the demo looks very good
     
  17. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    You're welcome. Thank you very much for asking how you can help! I will publish a draft of the new documentation tomorrow and will give you the link, it would be great to have your feedback. Also, yes, it would be amazing if you'd write a post about uTerrains on your blog!

    The outside looks way better with the fix, don't worry ;) However if you want to avoid any visible changes between LODs you should make the outside a bit bigger (ideally, 32 instead of 20 for example, so it is aligned with higher LOD).
     
  18. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @Ashkan_gc The problem with the shader (black faces) was actually an issue with tangents. I fixed it yesterday.

    Version 2.2 is on its way and should be available in about 2 weeks.
     
  19. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
    Got back to this today. When I tried to make the same cylindrical shape aligned with the Y axis like a well, then it only continued for say 100m and then stopped fully. Is that by design? a bug?

    code is

    Code (CSharp):
    1. /// <inheritdoc/>
    2.     public void Combine(float x, float y, float z, float[] values2D, float[] values3D, out float voxelValue, out VoxelType voxelType)
    3.     {
    4.         if (Mathf.Abs(x) < 20 && Mathf.Abs(z) < 20)
    5.             voxelValue = -1;    //y - height;
    6.         else
    7.             voxelValue = 1;
    8.  
    9.         float distance = 15 - Vector2.Distance(Vector2.zero, new Vector3(x, z));
    10.  
    11.         voxelValue = Mathf.Max(distance, voxelValue);
    12.  
    13.         voxelValue *= 1f / 64f;
    14.         voxelType = mainVoxelType;
    15.     }
     
  20. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @Ashkan_gc There was a bug indeed, I've fixed it and it will be shipped in the 2.2 update. Thanks again for the precious feedback.
    In the meantime, you can just set the vertical draw size parameter with the same value than the draw size (should be 4).

    BTW, I've tested your setup and found that the walls of your tunnel are too thin to be "seen" by chunks of highest LODs. To avoid this, you should either make the walls a lot larger (x <100 and z < 100 instead of 20 for example) or lower the level count of your terrain (and increase the draw size to compensate).
     
  21. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
    Yup I've tried to do that and the result was successful :)
     
    Amandin-E likes this.
  22. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Just a video of the future demo:
     
  23. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,009
    very nice, What is the shader used in the demo? RTP or your own?
     
  24. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Thanks! The shader used is RTP3 (triplanar vertex control version of RTP3). The shader which is included in uTerrains is just too basic to get such results.
     
  25. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Version 2.2 is out, coming with a lot of fixes and improvements!

    Enjoy!
     
  26. psyc1001

    psyc1001

    Joined:
    Jul 1, 2018
    Posts:
    1
    I wish to continue on the Spherical planet generation question asked before.

    1: If i used smooth generation i could create a spherical world, now if i used your grass and object placement could this handle the fact that my planet isnt facing up. aka would the objects align to the surface?

    2: Given the previous is possible, can i load multiple planets simultaneously? This is kind of key for my scenario. I will be using some form of hybridizing for showing planets at large ranges as you mentioned before due to the "player view range" it would stop rendering if i was like 500km away (should still be able to see a planet).

    3: given the hybrid nature do you have any suggestions for periodic snapshots of say the outer mesh? this way i would keep that loaded at minimum lod for the planet in space then switch at a suitable range.
     
  27. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Not with the current implementation. However, that would be easy to make trees and details follow the normal of the surface (but I'm not sur it's a perfect solution as they would follow all slopes)...

    One single terrain can generates multiple planets. And if you want them to look different, you can create different biomes (ie. one biome per planet).

    Interesting need, not easy to achieve. I think you should generate a low LOD mesh (or even a billboard) of your planets instead of trying to snapshot terrain mesh.
     
  28. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @ everybody

    Just so you know, I'm working on documentation, but also on a deep refactoring of Ultimate Terrains to better use threads. I hope to improve performance on the next update.
     
    killer1171090 likes this.
  29. killer1171090

    killer1171090

    Joined:
    Feb 23, 2013
    Posts:
    109
    Would it be possible for you to create a planet Demo scene? Just a large spherical terrain to demonstrate what this can do?

    Also my last question: Can this support Floating Origin (World moves around the player)
     
  30. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Yes I will do that but please be patient because I am working hard on the next update of Ultimate Terrains. This is a deep and complete refactoring to make code cleaner and maintainable, which also brings strong performance improvements.

    It does not have this feature for now, but this is something I have on the roadmap, and that should not be hard to do. I can't give any ETA however.
     
    killer1171090 likes this.
  31. crimsonmortis

    crimsonmortis

    Joined:
    Feb 21, 2016
    Posts:
    63
    Newish to Unity so I apologize if I word this poorly. It concerns physic and floating material. I see you mentioned coliders if I wanted to AVOID floating material is my only option to have each voxel check if it has air next to it in order to let it fall/collapse? I am using another Voxel plug in and it just slows everything down to much to do this, and I am hoping your system may allow for a better approach.

    Not sure if making a proximity check of voxels based on character vector 3 position would help this? Tempted to try it and see what happens.

    Is there a limit of voxel types that can be defined in the scene? Sorry if I missed that some where.
     
  32. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @crimsonmortis
    Detecting floating groups of voxels is not that simple because terrain is split in chunks. This algo https://en.m.wikipedia.org/wiki/Connected-component_labeling is probably what's need to be implemented but doing this by yourself will probably slow down everything as it should be done at the heart of terrain generation. Currently, uTerrains doesn't offer this feature. Maybe I will add this, but later.
     
  33. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    After reading through the documentation and having a fiddle in the editor I have a few questions I was wondering about :)

    Is there any way to set the size of the terrain without setting the size of the voxel (I only intend to have small playspaces)

    I'm unsure on how saving and loading maps works do you know where I could look to find this (I couldn't find where the heightmap in the heightmap demo was loaded for example)?

    And when playing the demos whenever I modify the terrain my whole game freezes for a second or so after. So I was wondering if you had any tips on optimization?
     
    Last edited: Jul 17, 2018
  34. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Terrain size is affected by 3 things:
    - draw size (the number of chunks of highest LOD to be drawn around the player)
    - LOD count (each time you increase it by 1 you double the size of the terrain)
    - voxel size

    All terrain settings are saved into the scene file. The heightmap of the heightmap example scene is referenced by the heightmap generator module, which you can find in the biome of the terrain.
    Appart from that, operations on the terrain (dig, add...) can be saved in json files (this is done automatically when you edit the terrain with the editor tool). These are saved in StreamingAssets folder.

    This is weird. One second is a lot of time! Does it happen with the editor tool, or when you are playing the scene? Can you try to build the game (as a release, final build) and see if it happens outside of the editor too? Did you encounter such issues with the playable demo from uterrains.com website?
     
  35. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    Thank you, ill start fiddling with lod stuff now :)

    And I just tried the demo on your website and that seems to work fine my fps just lowers a bit as I'm digging :)
    (My computer is quite old so it might just be poor performance of my computer)

    And I'm looking in the editor now and I don't see a streaming assets folder

    The uTerrain game objects in the editor say a filepath but when I try to check there it doesn't seem to exist?

    I don't seem to have a streaming assets folder in my whole project
     
    Last edited: Jul 17, 2018
  36. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    I found some things that look like what your describing in the "Tests" folder with the
    [{"o":{"t":"AddCube","o":{"p":[125.0,-18.0,16.0],"s":[1.0,1.0,1.0],"v":"Default"}}},
    and stuff

    But making a folder called streamingassets and putting it inside and adding the name of the file to the uTerrain doesnt seem to make a difference, the flat scene is still flat and and heightmap scene is still the shape of the heightmap, im not sure what im doing wrong :(
     
  37. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @joferjoe
    Unless you made modifications through the editor tool, it is normal that there's no StreamingAssets folder.
    I recommend you to try using the editor tool (in the editor tool tab of terrain inspector). Start the tool, select an operation (like Dig Sphere), set its radius to 5 for example, and click on the terrain to edit it. This will save your actions in the StreamingAssets folder and you will be able to see the arbo ;)

    About perf, the next update will come with strong performance improvements, and I have in the roadmap the possibility to perform operations asynchronously on the terrain so that it won't affect FPS.
     
  38. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    I tried editing in editor to try and get the StreamingAssets folder to show but im not sure it worked :oops:


    And them updates sound lovely im looking forward to it :D
     
  39. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    Oh it appears on play, thank you ill experiment now :D
     
  40. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    @joferjoe It didn't appear in the first time because you had to refresh the project view (right click on Assets folder, refresh). ;)
     
  41. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    @AmandineEntertainment is there any way to start with just a single 1x1x1 voxel sphere or cube in the center :)
    I still haven't wrapped my head around how the initial generation of a map works
    But now I know you can save and load adds and subtracts this seems like it would be a good place to start learning :D
     
  42. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    I recommend you to follow the getting started tutorial on uterrains.com to get the basics of terrain generation.
    Basically, all you need to do to create a terrain with a single voxel is to implement a generator that will set voxel value to -1 where you want to add your single voxel, and 1 everywhere else in the world. Then, use this generator in the biome and you're done.
     
  43. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
  44. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
  45. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    In the documentation, it says there's a smooth operation included, but I can't find it, is it just different settings for the flatten?

    Also is there any way to add ramps? (And if there is do you have any advice on how to achieve this)? :)

    Also is there any way to disable the loding?

    I only want to have very small maps (but be able to zoom very far away) :)

    And atm it dissolves into losing most its detail when zoomed out :oops:

    detail.png

    Would it just be a case of setting lods to 1 and increasing the initial chunk count in lod1? :)

    If this is the right way to do it how do I stop it disappearing when I zoom out instead of changing lods? o_O
    disapear.png
     
    Last edited: Jul 22, 2018
  46. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Indeed, the legacy documentation says it, but it's not true anymore :(
    But I will add it back. The next update is almost ready, and right after that I will work on adding more operations out of the box. Sorry for this.

    If you want to completely disable LOD, set the LOD count to 1 and increase the draw distance. (the initial chunk count per LOD won't change anything about that)
    Alternatively, if you want to keep, let's say, 2 LODs, set the LOD count to 2, increase the draw distance, and increase the distance between LOD 1 and LOD 2 to change the distance at which LOD will change.
     
  47. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    Thanks and nw ill just wait for next patch :D

    Roughly when do you think it'll go live? :)

    And thank you :)

    Also i saw on the 1st page of this thread that it features
    JSON serialization for network synchronization
    And i was wondering where to dig to find an example of this as it sounds fun to learn :D

    Is there an example in the editor tools somewhere because i guess how the add / remove / undo / redo stuff uses something similar? :)
     
    Last edited: Jul 23, 2018
  48. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    I'm sorry but I prefer not to answer this, because I'm doing it on my free time and I'm going to be on holidays soon :) I prefer not to tell anything than giving you a ETA that I could potentially not respect. Don't worry, you won't have to wait 6 months for it! ;)

    I really need to finish the documentation :)
    Get a look in the EditorTool script, there is a method called Autosave (that is called each time you modify the terrain with the editor tool). This method uses provided serialization functions to save operations.
     
  49. joferjoe

    joferjoe

    Joined:
    Feb 2, 2016
    Posts:
    95
    No worries on the date and thanks ill have a dig in that now :D

    Also I'm struggling to get performance as nice as the demo (while maintaining a nice draw distance)

    I'm guessing the demo is baked, but baking seems quite slow for just trial and erroring my way through the settings? :oops:

    By any chance do you have any recommended sizes for a fully baked scene? :)
     
  50. Amandin-E

    Amandin-E

    Joined:
    Feb 4, 2015
    Posts:
    436
    Nope, demos are not baked. They are purely dynamically generated terrains (and infinite BTW). However, they do use LODs, unlike you.
    I'm not surprised that you get poor performance if you increase the draw size too much. The best thing I can advice is :wait for the next release (coming very soon)! You'll see that performance is a lot better (from the first results, you can expect it to be at least 2 times faster!)
     
unityunity