Search Unity

Community Driven voxel terrain engine(All New version)

Discussion in 'Works In Progress - Archive' started by dudester, Sep 22, 2015.

  1. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    ah i see wierd , yeah no need for a shader although i did include a grass shader with touch bending as well as a script for the different parts of the body .
     
  2. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    hi all , so ive been doing some work on quixel terrain engine , and in doing so learnt quite a bit , so im going to start work on improving this engine , first fix is decreasing the noise sampling resolution to dramatically increase the generation speed , i saw a 2x increase in generation speed with just this fix , ill also start adding LOD support , read a great article on gpu gems about lod support , and this will have a nock on effect of reducing memory usage as well , so yeah thats all , will update with news.
     
  3. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    So ive implemented the sampling optimisation , next up is LOD .
    Does anyone here have any experience with LOD stitching ?
    id thought of just using skirts but it looks ugly , so im looking at either seams or transvoxel algorithm.
     
  4. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    so some good news , ive made some fixes to the grass shader , they include : fixed obstacle bending in shader , now bends much more realistically ,now the whole plant bends instead of just the leaves , also fixed up normal mapping , was a bit to strong , also fixed up wind movement so the plant moves more realistically.
    thats all im still fixing the terrain , adding lod support etc.
    my Terrain engine was denied by unity , apparently some kind of null reference exception , its been a plague on this engine , ill keep working on it and update when i can.
     
  5. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    Thx for the info and keeping working, Waiting to see new news about your terrain engine.
     
  6. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    good to see you came back to the project

    will try out last update sometime soon (damn google drive requires you to sign before you can download the entire folder)
     
  7. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    thats strange , ill look into making it downloadable for everyone , unfortunately progress has stalled , lod requires octree usage so ill have to learn that , ive also started on a game just for fun so updates will be slow
     
  8. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    well you can still download files without being signed it.. its just 1file at a time

    Anyway here are all the errors I have on importing and trying to run the Demo scene...

    Code (CSharp):
    1. Removing Assets/VoxelTerrain/grass because the asset does not exist
    2. UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
    3. UnityEditor.DockArea:OnGUI()
    4.  
    5. -----------------------------------------------------------
    6. Assets/VoxelTerrain/Util/IntPair.cs(6,18): warning CS0660: `VoxelEngine.DoubleKeyDictionary.IntPair' defines operator == or operator != but does not override Object.Equals(object o)
    7. -----------------------------------------------------------
    8. Assets/VoxelTerrain/Util/IntPair.cs(6,18): warning CS0661: `VoxelEngine.DoubleKeyDictionary.IntPair' defines operator == or operator != but does not override Object.GetHashCode()
    9. -----------------------------------------------------------
    10.   at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex, System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x000cb] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Array.cs:977
    11.   at System.Collections.Generic.List`1[VoxelEngine.VoxelChunk].CopyTo (VoxelEngine.VoxelChunk[] array, Int32 arrayIndex) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:198
    12.   at System.Collections.Generic.List`1[VoxelEngine.VoxelChunk].AddCollection (ICollection`1 collection) [0x00015] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:122
    13.   at System.Collections.Generic.List`1[VoxelEngine.VoxelChunk]..ctor (IEnumerable`1 collection) [0x00042] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:70
    14.   at System.Linq.Enumerable.ToList[VoxelChunk] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
    15.   at VoxelEngine.VoxelTerrainEngine.GenerateChunks () [0x0003d] in C:\Users\X7\Desktop\Unity\Voxeltest\Assets\VoxelTerrain\VoxelTerrainEngine.cs:401 Destination array was not long enough. Check destIndex and length, and the array's lower bounds
    16.  
     
  9. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    those are just warnings , i wouldnt worry to much about it.
     
  10. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    I see I had unity pause on errors so unpausing wasn't getting very far with terrain gen.. so with it off terrain loads up for a bit, still get this error spam after that last error above..

    NullReferenceException: Object reference not set to an instance of an object
    VoxelEngine.VoxelTerrainEngine.Update () (at Assets/VoxelTerrain/VoxelTerrainEngine.cs:311)

    ...another thing is that if you set the Grass array to 0 .. works but you get

    IndexOutOfRangeException: Array index is out of range.
    plantPlacer+<spawnstuff>c__Iterator6.MoveNext () (at Assets/VoxelTerrain/plantPlacer.cs:119)

    also i tried to get another the unity fps camera asset working, for some reason it wouldn't generate any terrain even though it was the only main camera in the scene and had the same MainCamera tag..

    anyway glad I got to try it out now, obviously its not finished and alot still to be done with it.. are you still working on the quixel terrain engine or just going to carry on with this and your own game project
     
  11. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    i see ill upload the new version with array length checking so those null reference exceptions dont appear , i had included a readme about how to use it , basically if you have no grass you gotta set the grass length to zero and the grass weights to zero as well , but ill include a fix that checks for null , and debugs an error log that is useful/
     
  12. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
  13. PandawanFr

    PandawanFr

    Joined:
    Nov 27, 2013
    Posts:
    68
    Hey, just wanna know, are you updating the Google Drive Folder?
    Or did you not update it so you have to give a new link?
    I'm thinking about using your filter, but I'ms going to have to change some stuff...
    I want to make my world with hexagon grids, dunno if I'll be able to modify yours, I'm just too lazy to create a whole new script while there's yours that's awesome!

    Anyways, keep up the good work!


    EDIT:

    Actually just not gonna use any Hexagons, gonna use your system, gonna be easier to manage and a bit more realistic, even tho hexagons would give a special touch to the graphics..
     
    Last edited: Nov 19, 2015
    f5fairy likes this.
  14. PandawanFr

    PandawanFr

    Joined:
    Nov 27, 2013
    Posts:
    68
  15. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    hi sorry for the late reply been busy with my new game , ill upload the new version soon which has twice the generation speed as well as improved usability , and im going to implement a splatmap type terrain so that you can use more textures, ive learnt quite a bit in my time away , so hopefully this shows in the new version .
     
    Arkade likes this.
  16. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    So some good news and some bad news , seems ive lost the infinite part of the terrain , but all errors are now fixed and any missing references will display proper debugs with useful information such as eg. if you have grass but no weights for grass then debug will pop up saying grass weights length does not equal grass length , then it will automatically add the missing grass weight as zero , so thats ll for now im busy uploading the new version to google drive ill update the main page with the new link and here . Thanks for reading , please report any bugs here .
     
    EliasMasche likes this.
  17. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    No problem with that, still very great job. Waiting for the new version of the engine.
     
  18. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    @EMGPY it'll take a lil while my internet speed a bit slow , also for anyone else out there making voxel engines there's a smart optimisation that works quite well , instead of creating noise for every voxel create noise for every second voxel and then lerp between the first and third voxel to get the second voxels value i found it improved generation speed by 2x . I learnt that from notches blog , ill find the link later on.

    On another note ive also made a planet maker while i was away , ive put that on hold while im busy with my game , but so far ive almost managed to get high resolution terrain im about 2 steps away , just need to figure out how to subdevide the mesh into sections then im done , maybe someone with some experience can take a look at it , anyway ill post that up soon as well.

    would there be any interest in parallax terrain shader for the voxel terrain?
    Proper parallax not unitys "parallax" .
     
    EliasMasche likes this.
  19. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    Really parallax terrain shader well be a substantial update and first i see in voxel engine terrain more open source. the bad side is about shaders i am still very newbie. don't have time yet to learn and still learning about voxels. so i can't help you in thechnicall side.
     
  20. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    i already have a shader for parallax , ive implemented it in the default terrain shader so moving that over to voxel terrain will be trivial , i suppose i might as well ill included an option to turn it off , its quite heavy ,but surprisingly i only loose about 2-5 fps with it on so not bad.
     
  21. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    sorry i havent uploaded it yet im battling unity 5.3.1 at the moment and also trying to implement lod support although there will be cracks but atleast there will be less memory usage
     
  22. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    so partial success with terrain its infinite again and has lod support a bit broken but working,so far so good , just need to figure out how to position chunks correctly based on there lod , it seems like ill need some kind system where i can check the available space between chunks and determine what lod could fit in there ? anyone know of such a system?
     
  23. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
  24. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    ah yes i see octrees are the only way , thanks for the link seems to have everything i need , i will have to start on that a little later on , ill upload the new version without the lod in the mean time.
     
    EliasMasche likes this.
  25. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Ok so for now you can pick a min lod to use , basically just a min voxel size starting from 1 to 9 , that might help with memory usage as each chunk can be doubled in size and no cracks , once the lod system is working ill re upload.
     
  26. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Old Link new link below
     
    Last edited: Feb 9, 2016
  27. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    Good that is the correct info, well when i have the time i going to download to test this version. and thx for the link.
     
  28. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    thanks hopefully it works well for you , please dont forget report any bugs you encounter here and ill fix them , as theres lots of code and finding all the bugs is quite tricky .
     
  29. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    I have this screenshots playing with the voxel engine. When activate Make Caves, The terrain goes crazy. :D , Some part are realistic mountain later you fall trough the terrain because was a cut. even create floating island. in the other side very good perfomance i have in my machine.
    CPU: i3 3120 2.4ghz
    GPU: HD 4000
    Ram: 8gb 1333mhz.

    When i hace time again going to play more.
    PD: When i play for the first time appears me 3 errors in the console and various warnings. close and open again unity there no was anythink in the console
     

    Attached Files:

  30. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Good to here the performance is good , strange that there's strange terrain when in make caves mode , what id suggest is look in your project folder and delete the folder called "Saved Chunks" , you need to do that everytime you change a setting in the terrain inspector , as for the errors in console , i have yet to track these down , if you could post a screen shot or even just a list of those errors maybe i can track them down , they are usually array length errors , im not sure if its a unity bug or not . Thanks for trying it out though.
     
  31. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    Well here are the error and 2 warning that appears when install for first time in the console.
    The warning are coming from IntPair.cs, and the error when you play. are from system.array outside of unity.
     

    Attached Files:

  32. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    This is very odd i think its a glitch in unity itself as i check the array length and at that file line i do check if the list.count is greater then 0 , so im not sure whats going on , this is not supposed to happen with list.add , maybe if i was directly indexing it or something , but i literally take the chunk at index 0 and since its greater then 0 all should be good ?
    Anyway thanks for posting that , for now i see no way around it , seeing as it only happens at the start and never again it should be fine.
     
  33. PandawanFr

    PandawanFr

    Joined:
    Nov 27, 2013
    Posts:
    68
    Ok, just tested it, looks awesome man!

    Now some things I found:

    - Grass doesn't seem to spawn (I tried in your Demo scene, I can only see two grass gameobjects in the scene, one is the "model/original" and another is a copied version but not visible.)
    - When you place a new voxel close to the player, you glitch inside and fall down
    - Also, I haven't found where, but if there isn't, could you add some sort of slider to change some values from the Noise such as the frequency, resolution, octaves... Just wanna tweak things
    - Is there a limit of how low you can dig, because after a certain point, I can't dig any more... Is that for memory purposes? Could I change the value?


    EDIT:

    Also, found a weird glitch, when I go to a certain height, the terrain doesn't have a collider anymore, and I fall
     
    Last edited: Jan 30, 2016
  34. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Interesting things you have found , the grass not spawning is strange ill take a look at it perhaps you didnt set the amount of grass in inspector ? if not then ill take a look at it see whats happening .
    Can't help with the player falling out of the world thats to be expected when you place a voxel down ,
    If you look in the inspector theres a thing called noise module if you find that it has all the sliders and stuff ,

    yes you can change the height its set to 256 voxels in the inspector by default but you can change that to what ever you want.Note high values will increase memory usage.
     
  35. PandawanFr

    PandawanFr

    Joined:
    Nov 27, 2013
    Posts:
    68
    Isn't 256 the max height? Because weirdly, I can't dig lower than 3-4 voxels down.

    Also, why am I falling after a certain height? Would it have to do with me changing the values, which doesn't completely override the saved chunks?
     
  36. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    strange i just tested it and i can dig all the way down , does it pop up with an error or anything? if not then maybe something strange is happening .
    No i doubt it , you should be able to change anything and the system should work , what do you mean by going higher ? building higher or just walking higher?
     
  37. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    its possible that the terrain is already quite low , and you are hitting the floor of the terrain.
     
  38. PandawanFr

    PandawanFr

    Joined:
    Nov 27, 2013
    Posts:
    68
    https://gyazo.com/77b88519c940addaa453eb28cfe13f09
    That's the problem for falling when high (note I'm on a mountain )

    Also I get these errors... https://gyazo.com/df44c5e9987456789174a55cefada716

    And lastly, the limit is, whenever the cube is at 118 y, I can't dig lower...


    EDIT: Also found out that the Saved Chunks folder is always empty... Is that normal?
     
    Last edited: Jan 30, 2016
  39. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    i see this is very odd behaviour , it all works perfectly for me , let me take a look at it again , yes the saved chunks only fills up if the chunks are changed and you save the terrain.
    I'll report back in a moment , possibly with an updated version with a fix.
     
  40. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Oh and thanks for reporting this , it helps when other people post errors as i cant test everything , cause i know the engine so well.
     
  41. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Ok solved the digging problem , seems its working just really really really ... slowly . as for the falling through the terrain , im not sure this should be happening , but ill continue looking .
     
  42. PandawanFr

    PandawanFr

    Joined:
    Nov 27, 2013
    Posts:
    68
    It looks like it has to do with loading chunks, apparently when I go to a certain region, the game tries to unload some terrains and reload the ones farther, but it doesn't work well as it basically unloads all chunks, maybe make some GameObject/Transform public variable so we can put the player's prefab and you can use that to base the chunk loading.

    (BTW, I am using Unity's First Person Controller, not the one you made)
     
  43. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    I can certainly do that , currently the engine uses the main camera , that is the camera with the tag maincamera on it as the place to load terrain at , but ill add a slot for it.
     
  44. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Update : I've decided to make this terrain engine a static terrain , meaning you specify a size and and then edit it in editor , instead of being runtime only , I'll update with news when i make some more progress
     
  45. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Update: i completely rewrote the engine , added a queue system to it , so finally those errors are all gone , added a slot for the camera , so terrain can now load around the camera of your choice , also the digging is working again at full speed .
    Will upload the new version shortly just doing some bug testing going to try break the engine if it works as expected then will upload.
     
    Tomnnn likes this.
  46. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Ok its official im uploading the new version , completely fixed and working perfectly .
     
    Tomnnn likes this.
  47. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Ok so for some strange reason unity is reporting a greater distance then what is the actual distance not sure why that is but its preventing me from walking anywhere on the terrain , cause as soon as i do the terrain unloads immediatly.
    So I'll have to fix it first before i upload the new version.
     
  48. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Solved the problem and fixed another hidden problem .
    @PandawanFr I solved the problem of the terrain disappearing below you while walking .
    Uploading now will post here with link and in title.
     
  49. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
  50. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Another Update I'm still working on editor terrain , also i've just made some changes to how the engine does texturing , it can now handle an infinite (yes infinite in a sense ) number of textures , so once i've got all this working nicely i'll update the google drive version.