Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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
    Update:Seems my neatening up of the code has broken the terrain engine ill have to take a long look at it , seems the terrain is no longer updating with the new noise values, so that's great(sarcasm) ,anyway ill update the github once thats fixed.
    Update2:seems the noise values arent working correctly , going to find another way of adding noise im thinking a module based system?
    i will update again with results.
     
    Last edited: Oct 2, 2015
  2. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Update:Fixed the error and ensured it never rears its head again , seems i made an oversight on the voxels , the voxels value needs to be added to half the max height for some unknown reason , none the less its fixed now , ive also begun work on a module based noise system as well , ive also fixed the plant placer script which wasn't distributing the grass evenly and randomly , also fixed the grass appearing everywhere , it now mostly appears on grassy areas and not on cliffs unless the cliffs have some grass on them.

    Thats all for now thanks for reading let me know what you all think .

    ill upload to the the github repo asap

    also @darkhog ive added the feature where the terrain can now be scaled, probably needs some testing but should work well for your needs.
     
    Last edited: Oct 3, 2015
  3. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    I think you should add additional, optional shader for terrain that instead of blending textures between different voxels uses old-schoolish tiling to make it sharper and better. Example, one of old screenshots of a voxel game called Blockscape:


    Look at how transitions between grass and dirt are done on the right side of the image. If the "regular" blending would be used, that would be just a blurry mess.
     
  4. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    wow that looks good , if you want different blending i suppose i could add an option to determine the blending of the textures , is that what you mean?
    you kind of want no blending basically ?
    Edit: wait never mind i see what you saying im no expert on shaders so this is kind of hard for me to do.
     
  5. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Yeah, kinda. Also it blends using tiling of textures, as in RPG Maker's (not sure if you're familiar, but it is easy to google) autotiles, only automated using some kind of "mask" that makes side textures bleed slightly but not too much and makes it sharp.

    Come to think about it, "regular" terrain could use such improvement as well.
     
  6. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    just found a great article on it ill start work on that right now , looks quite awesome and fun to write.
     
  7. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    :)

    Be careful, or you'll make it better than certain $3k voxel terrain engine on the Asset Store!
     
  8. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    lol thats what im hoping to create , im pretty much done with it although it still needs a bit of tweaking but ive got it where its blending the textures based on alpha value with a depth mask so it looks nice, going to add a slider for the depth as i think players will want to fiddle with it to get it where they want .
    Updated dev branch and master branch with the changes the shader is in there as well if @darkhog wants to try it out.
    Edit added a bit of fuzzy blending to it so its not so square looking can be set in shader
     
    Last edited: Oct 3, 2015
  9. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Cool. I probably won't try it now, because I'm focused on the current project which doesn't require any voxel engine, but may use it in the future.

    It may be a good idea to get it to the asset store.
     
  10. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Agree, otherwise someone else may do that before you & capitalise on all your work
     
    darkhog likes this.
  11. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    assetstore sounds like a good idea, ill make a demo scene and add some textures so people know what to do , it will be free and continously updated.
     
    tedthebug likes this.
  12. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    just thought id show off some screenshots of the shader and show my little hovel i built while i was bored .
    Unity 2015-10-04 04-27-47-21.jpg Unity 2015-10-04 03-37-18-24.jpg
     
    tedthebug likes this.
  13. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Nice, although it still doesn't look like Blockscape's tiling. There's too much blur/crossfading between grass and dirt, it should be sharp, like in case of Blockscape.

    Good progress though, keep it up! Also, maybe I've missed it, but any luck on option to increase voxel resolution if one wants to?
     
  14. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    you can just decrease the voxelterrain parents scale to scale the voxels down or up , still needs some work , yeah if youd like to have it like blockscape theres 2 sliders to change the blending and amount of depth
     
  15. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    another screenshot of some grass and some mountains Unity 2015-10-04 04-37-46-16.jpg and another screen shot of the the terrain shader but with its block like value changed Unity 2015-10-04 04-43-50-12.jpg
     
    tedthebug likes this.
  16. PandawanFr

    PandawanFr

    Joined:
    Nov 27, 2013
    Posts:
    68
    WHOA! This project is starting to get really super mega awesome (it used to be Awesome, but now...)!

    Anyways great work! I hope you'll keep it up (and possibly free).
     
  17. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    thanks , theres still a bit to do , id like to add normal mapping to the shader as that would make it look even better , just having a bit of trouble doing it , it seems that when i add normal mapping to the shader it streches the textures for some reason , its to be investigated , id also like to implement voxel water in this as its going to be pretty easy only problem is memory , also in editor editing of terrain will be implemented , although it will be a separate engine as implementing both at once will be to tricky .
     
    Last edited: Oct 5, 2015
  18. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    I have no idea what I'm asking but I'm curious as to the answer.

    Would it alter the speed/memory if the rendering was turned off when the items are not in the camera scene & then turned on when the player has them in view?
     
  19. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    i think i understand the question , yes the best way to reduce memory usage would be to unload data that is to far away from the player and only use data for chunks that are like 50 metres away or less so that you can dig and edit terrain around the player, but still have chunks display a mesh at a distance of up to say 4000 metres , but this is c# coding so garbage creation is a huge problem , thats why most are created in c++ as memory management is possible , my current way of handling the terrain is just to only load chunks at a certain distance seems its the only solution currently.
     
    tedthebug likes this.
  20. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Thanks for that.
    I was also wondering how rendering works & whether the chunks that are loaded around the player have any impact to usage if the mesh renderer is activated when in the camera view & deactivated when outside the camera view port e.g. To the left & right of the camera the chunks are loaded & there but the mesh renderer is turned off.
    I know that I can see these items in the editor so was assuming that in game the system was rendering them in the scene even though the player can't actually see them so I then thought it might lower processing if the mesh renderers were disabled for them when the player couldn't see them.
     
  21. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    its possible , it might improve performance slightly but not much , the best possible solution would be occlusion culling but since its dynamic its kinda tricky , also it doesn't use a mesh renderer , i use graphics.drawmesh for the rendering of everything except trees .

    To expand on this , unity automatically culls things outside of the view frustum , you can see this happening if you reset the mesh.bounds to a tiny value , the mesh turns off , so i assume unity simply checks if its bounds intersects with the cameras frustrum .
     
    tedthebug likes this.
  22. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Ok, thanks. Thought it was worth asking just so I learn.
     
  23. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    all good its good to know these things , i found them out by accident mostly , through a series of irritating bugs in my code .
     
  24. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Im just writing some documentation and ironing out some small bugs . In future versions ill add an option to do in editor editing as well as editor saving , but for the upcoming version ill just have the normal terrain engine with the terrain shader , it also comes with a shader which bends grass for three different objects i usually have it for the 2 feet and the body so that's a free bonus for all you out there .
    heres a screenshot of the blending options you have in shader id like to make a script that can access these options but that"ll come later.
    Unity 2015-10-06 16-59-10-39.jpg
     
    Last edited: Oct 6, 2015
    manpower13 likes this.
  25. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    Very great new, Waiting to see that changes. is great to see open source projects advance in a good way for community.
     
    Last edited: Oct 7, 2015
  26. Feeble1

    Feeble1

    Joined:
    Jan 20, 2014
    Posts:
    19
    Hello, I like your screenshots. I have worked on a voxel engine in the past and would like a look into yours.
    A couple concerns:
    There are assets missing from your repository that make the demo un-buildable.
    Also, the MIT license would require that anyone who uses an excerpt or whole of this code/engine to include the MIT license statement. That's great if that is what you want. But the ZLib license is a bit more open source friendly.

    Good luck with your headaches!
     
  27. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Hi @Feeble1 ill be changing the license so that it doesn't have to have all these terms , i really wish they had simple licence like this is yours its free to use as you will blah blah blah , none of this gibberish like terms and conditions etc ,anyway ill be releasing this on the assetstore with an assetstore license and it will be free , all i ask is for a mention in the credits , and if you feeling super generous a donation (lol) .

    Thanks .

    I havent had much time as of late , but i will have this weekend , so hopefully it'll be submitted to the assetstore by then.
     
  28. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    Well i think is your still searching a license, the best for here is WTFPL(Do What The F*** You Want To) Public License, A license that i like for my small code projects. This is the full license text

    Sorry for that word, well is the name of the license. :oops:
    More about this license is here
    http://www.wtfpl.net/about/
     
  29. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    sounds good ill look into it , im doing a bit of work this weekend on finishing the documentation it'll mostly just describe the various functions and other stuff , and basically how to get started i'm not going to go in depth as its a free asset , and time is money , but i still believe the community needs this , if you make it big you can pay me if you feel like it but a mention in the credits is a must , also after this ill be working on a new gravity system (i've already started work on it) based on einstein's theory of general relativity so far i've got all the features implemented , currently if you fling 2 rigid bodys next to each other and they both have gravity scripts on each other they will attempt to orbit one another and depending on its mass one will orbit the other faster , its 100% accurate and i've even seen moons form and full planets being made out of this so its quite fun to mess around with.
     
    tedthebug and EliasMasche like this.
  30. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    That's great, Waiting to see the ready version of your Voxel Engine and progress of your Gravity System.
     
  31. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Uploaded asset to the assetstore , now to wait for it to either be on the store in 2 weeks or rejected , guess we will see how it goes .
     
    tedthebug likes this.
  32. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
  33. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Good luck.

    Have you seen the 2d alpha video? Would be pretty amazing if this could be combined with the scriptable paint brushes to alter terrain as needed with height etc, or can that be done now?
     
  34. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    you could alter the terrain with a brush although for now only in runtime , although you could do that then save terrains.
     
  35. PandawanFr

    PandawanFr

    Joined:
    Nov 27, 2013
    Posts:
    68
    I don't think that's a big license as it doesn't say anything about crediting. It literally says "Do Whatever The F*** you Want", and I think it would be better to credit dudester.
     
  36. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    i agree im just gonna use the assetstore licence that comes with unity , as that licence is the best , also im gonna start work on a new version of the asset that runs in editor , so far i havent been able to figure out how to do both in one asset , so for simplicity sake , i'm gonna make it a different asset , as i think some people dont need infinite terrain .
    Also i want to add to the current feature list of the infinite one , i want to add meshcombining at runtime for the grass meshes , cause this is a major slowdown for the engine , maybe if someone has a readymade meshcombiner for me , i could combine it with my asset ? anyway those are my future plans , in later installments , a voxel water will be added .
     
  37. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
  38. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    sure could although im not sure what the creator of that would say maybe me and him could collaborate to make that available ? do you know his name on unity ?
     
    Last edited: Oct 14, 2015
  39. EliasMasche

    EliasMasche

    Joined:
    Jul 11, 2014
    Posts:
    92
    Here is the Thread in the Community, and the username is @12pt in unity forums
     
  40. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    thanks , ill speak to him although i must say his implementation works well out of the box , so i really couldn't see any improvements being done by collaborating except maybe convenience .
     
  41. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    the asset is still pending review obviously some kind of hang up , i've got a feeling that i'm gonna get the asset back with a ton of comments saying i need to fix stuff.
     
  42. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Looking forward to trying this out dudester, certainly the open source of it appealing, I've seen and tried a few voxel engines/assets but haven't settled on one to use for my own game yet.
     
  43. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    good to hear @Player7 , this asset doesn't work as well as some of the assets out there such as terrainEngine , but it does the job , i dont know if you have played 7 days to die , this terrain is very similar to it , terrain view distance is a max of 1000 or 2000 units , im still waiting on the assetstore to review it , im gonna upload to google drive in the mean time so players can test it out ,
     
  44. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    actually ran a server for that game, i did many server sided c# mods for it, so i'm very interested in anything that comes close to its smooth voxel terrain, wouldn't say its a great engine as it seems to follow the minecraft sort of chunk sizes etc with 16x16x256? which was never so great on view distances.

    For me i'm less interested in random terrain gen worlds, as I'm wanting to have premade worlds using voxels to provide a terrain that is destructible, don't think it needs to be on the way of infinite i tihnk 1000 or 2000units view distance would be fine, is is possible to use like multiple voxel patches where those areas can be fully editable ingame, and just build a world that has both static terrain and voxels.. sounds large enough though. I think this project you've started will be good for me to get started, something that is still small enough for me to read the code and try to get an understanding of it or go from what is documented use it like that.. I haven't tried the other store assets but closed source or just very large in features kinda scares me off, though I guess in the end it will be which ever I can work with and has all the high level stuff already working that i will use. Right now though I'm just exploring what there is and what would work best.

    "voxel terrains are the future , its just most popular game engines haven't been working on them , if they did it would be brilliant , even though unity terrain gets called bad and all that , its actually really good it uses virtually no memory and its highly optimized , if unity could create a voxel terrain imagine how nice itd be."

    yeh it seems game engines like unity/unreal are still ignoring it, would be nice if unity/unreal would actually start providing a base starting point of tools/features/ voxel gameobject where you can set the sizes, have the game engine take care of splitting that for storage/networking based on what works best... at least then people making assets could make assets and enhancements for something that everyone has, instead of many different voxel engine approaches, and not as much polish on the entire thing as no one is really selling usability enhancements for any particular voxel engine asset, and its usually just 1 lead dev on most of them if they are even active. Unreals large map stuff seems like step in the right direction for large worlds..something 7dtd suffers from with terrible jittery lighting/entity calculations when a player gets past 3000 blocks from center of the world.

    So things like the performance, networking, ai path finding and terrain editing tools for non random gen based levels all worked much like the existing tools for classic static terrain etc probably easier to ignore and let custom assets be developed and game devs with more technically skilled people can tackle it for there type of game. But for the indie dev who isn't notch etc just want to get on with making a game within a voxel type game engine that has more of the higher level issues and performance stuff taken care of its not so easy.
     
  45. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    maybe check out cubiquity for unity3d they have static terrains that are editable , my terrain is more random generation like 7dtd it is editable and can be saved so if you change the terrain in runtime all changes are saved , although i still want to add grass location saving (lazy ) , that will come in a future update , all files are c# scripts so if you want to you can change what ever you want , if you do come across a better / more optimized way of doing anything do let me know as it seems like you have some experience in the field .

    some things to look out for in the scripts is the possibility of adding lod support of some kind , this would be handy as it would allow more of the terrain to be generated , also check out an engine called quixel terrain engine , its been buried over the months but it uses dual contouring and has lod support already , all it really needs is voxel editing then its all good to go .

    This engine doesnt suffer from lag at all due to a small chunk size (less computing per chunk in terms of physics ) and multithreading so it should run fast on modern hardware , in future versions id like to implement some kind of thread system based on how many cores the pc has so better pcs load the terrain faster .

    networking should be simple , although untested all you would do is send the voxel data as chunks are edited , would require a main server which handles all clients chunk data , as for pathfinding well a-star pathfinding should work , its gonna be added to the terrain engine as a feature hopefully with a simple calculatepath(Vector3 target , Vector3 position) function .
     
  46. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    just to let everyone know i've started a collaboration with @Chippington on his voxel terrain so work on this engine will be delayed quite a bit , if all goes well we might see a much better terrain engine come about .
     
  47. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Old link new link in op
     
    Last edited: Jan 19, 2016
  48. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
  49. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    strange , just to confirm can you check in the util folder if there is a doublekeydictionary.cs
     
  50. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    It was an issue caused by google drive. For some strange reason it didn't incude the util folder in the zip.
    Is it ok if the grass has no shader?