Search Unity

TerraVol: volumetric/voxel terrain system. Dig holes caves in your terrains!

Discussion in 'Assets and Asset Store' started by Amfu, Apr 9, 2013.

  1. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Thanks so much for the reply :) this has helped me a lot

    THe following is probably a real newbie question... but thought I'd ask anyway since I'm totally new to the world of voxel generation.

    Is it possible to use LOD on the map .. so for example the map could have 32x32 size blocks when viewed at a distance but 1x1 size as you begin to dig close-up ?

    I'm about to test this on my iPad2 this will be interesting .... hhhmm

    running on Macbook Pro - Unity4 Pro iOS license
     
    Last edited: Apr 25, 2013
  2. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    Your welcome!

    Unfortunately no, you won't be able to do this because TerraVol uses its own meshes, internally built, in order to be able to quickly alter geometry. In other words, there is no way for now to convert a standard terrain to a TerraVol terrain. This actually gives me an idea: I could make a script to generate a TerraVol terrain from a height map, so you could do what you want to do. But this will take some time and won't be part of the next version. I'll let you know if there is any progress on this point ;)
     
  3. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Actually allowing heightmap to voxel generation would be pretty good, would mean i can integrate this in my current (heavily heightmap based) workflow and add the non heightmap possible features at the end.
     
  4. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    This is funny you're asking for LOD system, because I'm currently working on it. Currently, TerraVol doesn't support LOD. But work is in progress. It won't be in the next release, but maybe in the next-next-release. The difficulty is that it will oblige to build more chunks on each frame when the player moves... It's more difficult than it appears.

    If you have any other question, do not hesitate to contact me again. You can reply on the forum or send me an email to terravol.unity@gmail.com if you have more specific questions. ;)

    Thanks!
     
  5. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    Noted! If this is important for many people, I will increase the priority of this task in my development process.
     
  6. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
    Converting to a heightmap to a voxel density is actually really easy - basically just iterate through the voxels and set the density like so. I did something similar with MRI information and voxelform

    Assume you have a 10x10x10 block, and a 10x10 heightmap, which is a grayscale texture, white = highest, black = lowest.

    You'd do something like this:
    Code (csharp):
    1.  
    2. int zheight = 10;
    3. float density = 0f;
    4. float currentDepth=0f;
    5. float currentPixelColor=0f;
    6. float strataSize = 1f / (float)zheight;
    7.  
    8. for (int z=0; z < zheight; z++)
    9. {
    10.   for (int x=0; x < 10; x++)
    11.   {
    12.     for (int y=0; y < 10; y++)
    13.     {
    14.        currentDepth = (float)z / float(zheight);
    15.        currentPixelColor = heightTexture.GetPixel(x,y).r;
    16.        if (currentDepth < currentPixelColor)
    17.        {
    18.           //full density
    19.           density[x,y,z] = 1f;
    20.        }
    21.        else
    22.        {
    23.           //falloff density (floored to -1 since that's the lowest density possible).
    24.           //We multiply by 2f since in this toolkit, the density seems to range from -1f to 1f.  
    25.           density[x,y,z] = Mathf.Max(-1f, 1f - (currentDepth - currentPixelColor) / strataSize * 2f));
    26.        }
    27.     }
    28. }
    This is sort of pseudocode and untested as I don't have this voxel toolkit, but you get the idea.
     
  7. ikelaiah

    ikelaiah

    Joined:
    Apr 15, 2013
    Posts:
    154
    runonthespot,

    Then, similar pseudocode can be used to convert mesh data into voxel as well, is that right?

    -ikel
     
  8. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
    Yes, kind of. The problem is slightly trickier, as you have to infer a height map from the mesh, which if it isn't a grid / regularly spaced, is much much trickier. If you wanted to avoid the slightly horrible geometry involved, I guess you could stick a mesh collider on it, and cast a bunch of rays to sample the depth. Pretty nasty solution though.
     
  9. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
  10. ikelaiah

    ikelaiah

    Joined:
    Apr 15, 2013
    Posts:
    154
    runonthespot,

    Thanks for that link. It would work well if your terrain if flat. If your terrain has overhangs, then it won't work.
    What an interesting discussion...
     
  11. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    Thanks Runonthespot!

    This is actually the kind of algorithm I was thinking about. It's very kind of you to give me this piece of code, it helps and saves time :)

    @ikelaiah
    Like runonthespot said, I will develop a way to generate a terrain from a heightmap, but you will have to "convert" your terrain to a heightmap with another tool like the one given by runonthespot. This way, you will be able to import your terrain in TerraVol ;)
     
  12. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    You mean you have a terrain mesh with overhangs and want to convert it to TerraVol terrain? This would be a lot trickier actually. Still possible through rays cast (at least in a first solution) but not as simple as reading a heighmap.
     
  13. runonthespot

    runonthespot

    Joined:
    Sep 29, 2010
    Posts:
    305
    Pleasure @amfu. I love voxel solutions. I bought voxelform when it was available, but it's a little high-poly for easy use-- have you tried it? I ask as I might be interested in purchasing TerraVol if it's markedly better/faster.

    @ikelaiah, don't forget that overhangs etc would not normally be possible with a heightmap anyway. In some respects if a terrain with height maps is all you need, you might be better off with a plain mesh.

    Much more interesting for generating realistic landscape from voxels is a combination of good noise algorithms and triplanar shading with great textures.

    bear in mind that all you need is a 3d perlin noise function or similar something that takes x,y,z and returns a value 0..1 (double it subtract 1 for this toolset) and you'll have procedural terrain.

    Libnoise is a great place to start for that (and there's coherent noise on the asset store for free I think?)
     
  14. ikelaiah

    ikelaiah

    Joined:
    Apr 15, 2013
    Posts:
    154
    @ All,

    Thanks for the update. The reason I mentioned about overhangs, because some project that I will be working on involves overhangs for an accurate geo-spatial visualisation.
     
  15. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    I've never tested Voxelform. I always try to optimize TerraVol to get better performance, but currently there is no LOD system and so you might find it high-poly too. I'm working on it, it's one of my top priorities.

    Actually terraVol already includes a combination of 2D and 3D Perlin noise in order to generate realistic landscapes. In the next release (coming very soon), I added some parameters which will allow to change the height of cliffs, hills, etc. to get exactly what you want.
     
  16. Yoshinat0r

    Yoshinat0r

    Joined:
    Jan 17, 2013
    Posts:
    3
    This just looks amazing! :eek: I'm wondering, how customizable is the random terrain generation? Is there any way to tell it to randomly generate game objects within the terrain (so they could be like found underground)?
     
  17. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    Hi Yoshinat0r!

    In the next release of TerraVol (which will be available on the Asset Store within one or two days!), terrain generation is customizable via different parameters allowing you to choose how your terrain would look like. You can already see it in the new documentation here: http://terravol.com/doc/Doc.pdf if you look at "Setting Map Generator parameters" section.

    For now, the only way to randomly generate game objects within the terrain is to customize scripts. A good way to do that is to implement the ITerraVolEnhance interface, or you can directly modify TerraVol sources.
     
  18. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    Hi everybody,

    I'm pleased to announce that TerraVol 1.04 is now available on the Asset Store.

    This new version includes several improvements:
    - dynamic terrain generation (at runtime) allowing to have bigger terrains with lower loading time
    - new parameters to customize terrain generation
    - possibility to compute mesh tangents just by checking a box (required by some shaders)
    - refactored Builder.cs with public attributes to change size of brush and digging speed (easier to understand)
    - improved doc
    - a bit of refactoring on Map and Map Generator components

    You can also get a look at the new documentation here: http://terravol.com/doc/Doc.pdf

    Thank you very much for your time
     
  19. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Thanks for the upgrade Amfu ... these new features sure make TerraVol shine :)

    I've been playing around the past few hours with the new terrain generation controls must admit its so easy to get some real nice looking environments flowing around my game. I purchased an advance shader kit that has triplaner shaders.. so next up (after a fe hours sleep) I'll try to add a personal touch to my design.

    But hey.. awesome work, such a great asset... loads of Fun :)
     
  20. Ostavius

    Ostavius

    Joined:
    Feb 14, 2013
    Posts:
    9
    Perhaps someone already asked: Are all future Updates included, when i buy TerraVol now?

    Or will i have to buy those functions again?

    2nd question: Is it possible to create endless terrains procedural with this Engine?

    3rd question: Basic fluid generation: Like Lakes and Rivers?


    Thanks for your answers :)
     
  21. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    Thank you very much Banksy! I'm very glad you're happy with TerraVol :)

    @Ostavius
    Yes, all upgrades are free through the Asset Store. You will pay only once.

    2) It's theoretically possible to create endless terrain with the new version, thanks to dynamic generation. However, keep in mind that you will have other problems with an infinite world, like floating point accuracy issues, or too much of polygons in the scene...

    3) Yes, like lakes and rivers :)

    Thanks!
     
  22. Ostavius

    Ostavius

    Joined:
    Feb 14, 2013
    Posts:
    9
  23. Ostavius

    Ostavius

    Joined:
    Feb 14, 2013
    Posts:
    9
    can your engine create landscapes like this, because the landscape in your demo looks so smoothed.:
     

    Attached Files:

    Last edited: May 3, 2013
  24. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    It is not possible to create terrain like this With Marching Cubes.
     
  25. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Why not? If you look closely the geometry seems rather low poly it's just well textured no?
     
  26. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    Marching Cubes need Density for each Voxel. It's praticaly impossible to find the correct density for make Mountain Pic, 90° angles.
    And all voxels position have the same distance.
    [] [] [] , So you can not make random Pic with random distance Like on this screen :
     
    Last edited: May 3, 2013
  27. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Sounds more like a perf issue with voxel density, i've definately seen very large detailed steep close far angles on voxel based solutions.
     
  28. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    No , you can search. There is no marching cubes terrain with Pic like on this screen.
     
  29. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I don't know about marching cube specifically, but i myself use a voxel based tool that "can" make terrain like that, i'm using right now, this very second.
    Now i don't know how it ends up perf wise (i export to meshes) but it definitely can generates such terrain and is density based.
     
  30. Ostavius

    Ostavius

    Joined:
    Feb 14, 2013
    Posts:
    9
    ok, i am a little confused...
    is TerraVol the same as TerrainEngine?
     
  31. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    ? No. i'm the creator of TerrainEngine , but i can reply to another thread :). TerraVol creator is Amfu.
    Twice systems use Marching Cubes Algo. So i can reply cause i know how it works.
     
  32. Ostavius

    Ostavius

    Joined:
    Feb 14, 2013
    Posts:
    9
    oh ok :) What i meant was, not the graphical thingis like the texture, but the Landscape on the picture looks much more "natural" than the landscape in the demoversion. In the demo everything is so "rounded" and smoothed. I miss the roughness of mother nature :)
     
  33. Wild-Factor

    Wild-Factor

    Joined:
    Oct 11, 2010
    Posts:
    607
    There is no reason of not been able to do pic with marching cube.
    (there is pic in terravol screenshot)
     
  34. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I don't get it either, i don't see why voxels wouldn't be able to do something like that at all.
     
  35. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    There are no pics on screens. And it's not possible. You can try with all noises you want. It's impossible to make the same terrain.
    You can not have the correct density with biome generator. All terrain that will be proceduraly generated, will be smooth.
     
  36. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    What you're saying makes no sense
    1) No one said this has to be proceduraly generated
    2) You can very much generate non smooth terrain procedurally, i'm using that right now once again, i have very unsmooth terrain canyons mountains as well as hilly areas getting generated from a voxel tool.
     
  37. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Actually here's a counter exemple, simply mesh, generated procedurally by a voxel based tool and exported to a mesh, includes both hilly mountain areas as well as very steep near 90 degree canyon. $Capture.JPG
     
  38. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    1) The terrain on screen is not created by graphist, it is looking procedural. (Heightmap i think)
    2) And again. No, you can not have the same result. Or prove with some screens/links/video.
     
  39. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I did prove it with a screenshot. Does it not display above?
     
  40. Psyckosama

    Psyckosama

    Joined:
    Mar 20, 2013
    Posts:
    88
    How about we let Amfu come in and tell us what his engine is and isn't capable of. Okay?
     
  41. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Seems like the debate will go on until somebody can post a screenshot of the engine creating the terrain like in the pictures eh?
     
  42. BIG-BUG

    BIG-BUG

    Joined:
    Mar 29, 2009
    Posts:
    457
    @ronan: I can't see a screenshot in your post.

    As a general thought:
    -Displacing vertices randomly should help to get a more chaotic and natural look.
    -Also one may even use different looking geometry per case

    Obviously you coultn't use it for artifical structures...
     
  43. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    Hi,

    What a debate! :)

    To my mind, Marching Cube allow to create less smoothed surfaces. The thing that make terrains so smooth is the way it is generated, using Perlin noise.

    If you introduce random and arbitrary artifacts near the surface (i.e. near 0 isovalue) you will be able to have rough surfaces.

    I tried it for you (see screenshots below). As you can see, you would need to improve the shader used for terrain material in order to apply rock textures to artifacts.
    Also, the way I made it is very naive and it would need more work to get a more realistic look, especially, it creates sometimes a few rocks that are "flying" in the air (see red circles in the last screenshot)... But my goal here was just to show you a basic try, it could definitely be improved.


    $plop5.jpg

    $plop4.jpg

    $plop3.jpg

    $plop2.jpg

    $plop1.jpg


    To obtain this result, I simply created artifacts by adding this small piece of code in the generation loop:
    Code (csharp):
    1.  
    2. if (Random.Range(-1f, 1f) < 0) {
    3.     isovalue += Random.Range(Mathf.Clamp(Mathf.Sin(x+z), -0.05f, 0f), 0.01f);
    4. }
    5.  
     
  44. Ostavius

    Ostavius

    Joined:
    Feb 14, 2013
    Posts:
    9
    Sorry, i don't know why, but i can't see any screenshots
     
  45. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Same, happens on off on this forum with attachments :(
     
  46. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
  47. Ostavius

    Ostavius

    Joined:
    Feb 14, 2013
    Posts:
    9
    yeah, this is what i wanted to see :) thx
     
  48. Amfu

    Amfu

    Joined:
    Apr 9, 2013
    Posts:
    180
    Hi everyone,

    Just to give some news, I'm working on the next version of TerraVol. This will be a minor version change to fix some bugs and allow in-editor terrain construction and modeling (I'm sure it will save you time!).

    A bigger release is also under development, and will be available later. This one will include enormous optimizations and multithreading. This major version should also come with L.O.D system.

    Thanks to everyone for making TerraVol even more interesting!
     
    Last edited: May 8, 2013
  49. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Will you also be making sure that the bigger release is mobile compatible?
     
  50. Ostavius

    Ostavius

    Joined:
    Feb 14, 2013
    Posts:
    9
    will this still be available to those who bought the current version?