Search Unity

Assets Voxel Play - infinite world generator

Discussion in 'Works In Progress' started by Thrawn75, Jan 2, 2018.

  1. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Noise viewer and generator tool:
     
  2. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Version 3.3 will be released tomorrow Wednesday with new tools and improvements.

    Cellular noise generator has also been added to the Noise Generator tool:
     
  3. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Improvements coming to v3.4:

    Sunset & water speculars:


    Improved third person controller:
     
    digiross likes this.
  4. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    @Qmask this is fixed in latest beta version. The update will be available shortly on the Asset Store. Thanks for the heads up!

    EDIT: Update/fix on the Asset Store as well.
     
    Last edited: Mar 8, 2019
  5. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Feature preview: model definitions as inventory items.

     
    Last edited: Mar 16, 2019
  6. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Voxel Play 3.6 feature preview: curved projection.



    EDIT: 3.6 now available.
     
    Last edited: Mar 19, 2019
    HeadClot88 likes this.
  7. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
  8. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    968
  9. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Hi,
    It’s quite easy to create such tool using Voxel Play. The asset includes a simple demo scene which allows you to paint/clear voxels in a similar fashion (like a voxel editor) and you can convert any 3D array of colours to optimised voxel gameobjects with a single function call.
    There’s in fact some voxel editors under development using Voxel Play AFAIK.
    Regards.
     
    jGate99 likes this.
  10. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    968
    Thanks for your reply, im gonna check and let you know my thoughts.
    Im personally not good at 3D programming (mostly 2d with canvas ugui expertise) so plugin like yours could be a huge life saver.
     
  11. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
  12. CodeHuang

    CodeHuang

    Joined:
    May 10, 2019
    Posts:
    1
    Hello, I want to make a voxel-based large-scale map, can I only use the map component. My game is a third-person shooter. Do I have my own voxel character model and action? Specifically, it means that you can simply export a voxel scene based on unity to my team to place what they want to design, and to place people or tasks. Thanks, I noticed that the community is very active. From Google Translate.
     
  13. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Hi,

    if you don't need terrain destruction or transformation, then yes, exporting the world map into static meshes with optimal materials is a feature that will be introduced soon in Voxel Play and can help you. Basically this feature will generate and export the voxel chunks within a world area into regular gameobjects so you can afterwards remove Voxel Play and keep the generated terrain.

    Regards.
     
  14. bingofly

    bingofly

    Joined:
    Sep 15, 2018
    Posts:
    24
    @Thrawn75
    Hi,
    Happy to get this good asset. I have three questions.
    1st. Dose it support custom algorithm for terrain generator?
    For example: I don't know what kind of algorithm this asset use, maybe perlin noise, and can I use cellular automaton to replace it?
    2nd. In the document, I found every object is about cubes (voxel). For example the trees is constructed by cubes.
    My question is can I replace a cubed tree with other model without cubed structrue?
    3rd. It's not easy to handle pathfinding and local avoidance in a voxel-based large-scale map.
    Dose it have any solution?
     
  15. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Voxel Play is extremely extensive in this matter. You can 1) customize the provided terrain generators, 2) clone them and modify/tweak their code or 3) completely write your own terrain generator from scratch and plug it into VP.
    Here're some useful resources:
    https://kronnect.freshdesk.com/support/solutions/articles/42000001906-terrain-generators
    https://kronnect.freshdesk.com/supp...42000001950-coding-your-own-terrain-generator

    It also includes a noise generator (which produces tileable textures) that supports Perlin and Cellular types.

    Yes, VP supports custom voxels. A custom voxel is a voxel that uses a custom mesh:
    https://kronnect.freshdesk.com/support/solutions/articles/42000049143-custom-voxel-types

    VP can generate NavMesh automatically for you for all visible chunks. It does automatically and it uses a greedy mesh algorithm to optimize vertex count - then they can be just used as they're for AI as shown in one of the demo scenes included in which some foes track the player round.
    Note that NavMesh are dynamically generated, they're not available in Editor time so its use can be limited atm. You can define which voxel types contributes to NavMesh generation (ie. exclude water voxels) but you cannot have different path-finding rules for different foes. It's one for all solution. If you need more control about AI you need to provide your own solution (or extend what VP does).

    Regards
     
  16. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Hi everyone,

    Here's a nice introduction to Voxel Play from The Messy Coder. He shows how to convert an existing terrain (including vegetation and trees) into Voxel Play:


    Enjoy :)
     
    Adrad and digiross like this.
  17. futurewavecs

    futurewavecs

    Joined:
    Jul 26, 2012
    Posts:
    68
    I've played around with making Voxel Systems a few times. There were a few features I had been thinking of doing. Perhaps they are something you could do instead. I don't need the fame or time to support my own system. :) For all I know it may already do this.

    Since cubes are a set of specific vertices I had the idea to allow a variant cube type that allowed a person to specify the vertice coordinates for that type and spawn a new voxel type from it. I planned on keeping it constrained to the size of a cube. This could be useful for creating rough walls, ramps, etc while still essentially maintaining the same grid (voxel) reference.

    I also had an idea to make height dependent vertices like you appear to potentially be doing with liquid. That is what I was going to use it for as well. The idea was a height could be specified (I was either allowing 8 or 16 height variations depending upon the version of my project) For similar voxel types they would average where their edges met based upon adjoining heights. This could in theory be used to create rolling hills and more natural looking terrain. Yes, it skews from the Minecraft concept but it could have potential. Perhaps in making piles of ore or material that change in height.

    I also considered an inverted version of that where the height was from top down... good for making more natural cave ceilings, etc. This could be easily a concept applied in any direction to achieve more natural looks while still conforming to the voxel grid.

    Marching cubes of course would also address that which while being able to define the 256(actually less than this) styles of marching cube voxels might be useful, what I am proposing would be a little easier I believe.

    The final type I messed with quite a bit was a multi-voxel. I made it so I could mix dynamically defined voxels as per the specific vertices example above and create multiple voxels within the constraints of a single voxel grid position. This I then used to create trees, mushrooms, etc that still had the same look and feel but only would occupy the grid space I defined.

    I think that is about it for now. I'll dig into your system more soon. You did a lot of stuff I only dreamed of but never got around to doing (like the GPU portions). Your system runs quick and does a great job.

    Keep up the good work. Don't take any of this as criticism. When I find good asset creators who have already done a lot of the work needed on something I dream of having I'll often share those ideas to see if they are interested.


    Just so I back up my claim - here are screenshots from one of my earlier experiments from 5 or more years ago. The trees and some things under the water are made with the multi-voxel technique. I'd use it to make the trunk's of the trees slightly less wide than a normal voxels so even when trees were side by side there would be some visibility past the trunks.




    Then awhile later I did some other experiments... the stairs in this are also a multi-voxel. The tilted block was me just messing with fixed rotation which you have more than accomplished.



    I wrote about it a little more here if you wish to read any further about it.
     
    Last edited: Jul 9, 2019
  18. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Hi! Thanks for sharing your previous work.

    In Voxel Play, anything different from the standard block types can be defined using "custom voxel definitions" as explained here:
    https://kronnect.freshdesk.com/a/solutions/articles/42000049143-custom-voxel-types
    (standard block types refer to the render types provided by regular blocks in Voxel Play, like opaque 3-sided, opaque 6-sided, cutout, etc.).

    A custom voxel definition uses the mesh from a given prefab. VP can either instantiate it (if you want to preserve the prefab colliders or any attached script) or just render it using GPU instancing or Compute Buffers for performance reasons.
    For example, scattered ramps could just be instantiated (dynamic batching will take care of draw calls). Custom voxel definitions are also used for custom vegetation.
    The custom voxels use a specific material/shader that respects certain lighting effects, like day/night cycle or integrated fog.

    The height is an attribute of each voxel but it's only used for water voxel types atm. Reason is that water voxels are transparent and don't cast shadows or AO (there're a few performance tricks that assume the standard blocks are cubes like integrated AO or face removal).
    Custom voxel definitions, since they can have any shape, can't do face removal of adjacent blocks nor cast AO on regular block types. In that case and if you want AO on those custom voxels you can use a screen space effect instead. However the integrated AO is super fast and designed for mobile (no full screen post effect).

    VP also generates optimized meshes for collision and NavMesh. It uses a greedy-mesh algorithm to reduce vertex count and optimize the physics/navmesh baking when chunks are updated. This algorithm assumes the blocks are fully regular so height-variant voxels would require to implement their own colliders which is why they fit well as custom voxel types and default instancing.
     
  19. futurewavecs

    futurewavecs

    Joined:
    Jul 26, 2012
    Posts:
    68
    Yeah, I ran into that too. I'd usually include some consider for occlusion bits in the 6 directions so that I'd know whether to treat a side of the custom voxel as fully occluding or not.

    Anyway, thanks for your response. I did read up on the custom voxel and watched your demo with the half-block but I hadn't put it fully to the test. I will do so.

    I really like your tool and am glad I purchased it. It does many things like I said that I only dreamed of. I made some nice looking scenes but as usual with voxels trying to optimize performance then became a big focus. The screens ended up looking well for the art direction I was seeking but that was largely due to good choice in textures.

    I look forward to seeing what I can do with Voxel Play. I'll end up replacing all of the textures, and I have a few things to try out with it. A lot of what I need to accomplish is not a problem within the confines of your tool. I need to implement longer distance pathing for NPCs rather than slaving them to a chunk.

    EDIT:
    One reason I did the multi-voxels instead of a separate model is that I built it using the same textures in the texture atlas so even though it was more complex it greatly reduced draw calls by being able to pull from that atlas. It also enabled me to mix and match different textures per face for each of the components of the multi-voxel. While it would not fit within the culling and such as you have them now... if used sparingly they can be a nice feature.
     
  20. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    New major update released!


    Key changes include realistic water option and improvements to override material option, third person character controller, see-through effect and much more under the hood. Many changes related to integration and API.
     
    digiross likes this.
  21. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    249
    I found Voxel Play yesterday and I am quite impressed. I've watched all the videos and read everything in this thread and this asset is developing nicely. Well done! I own a couple of your other assets and like your commitment and being thorough. I will be purchasing soon. :)

    One quick question, would it be possible to add/modify to make procedural roads to go with the buildings?
     
  22. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Absolutely, but you have to add your code to paint the road voxels. Voxel Play is quite flexible in terms of what you can do. It's designed so you can either customize, extend or provide your own terrain and detail generators.
    A detail generator is a special class that adds, removes or modifies contents in the voxel world as it's being generated. Voxel Play calls your detail generators when needed (as the player moves around the world) so you can for instance paint roads between two points in the world before those chunks are visible by the player. Certain complex content is easier to create in a detail generator.
    Or you can also customize, duplicate or add your own terrain generator. A terrain generator fills chunks as they're needed by the engine. So you could create a variant of the default terrain generator that in addition to plant bushes or trees, paint road voxels at the surface based on your own logic.
     
    digiross likes this.
  23. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    249
    Wow quick response! For years there have been half-hearted asset store attempts at voxel worlds and this asset of yours seems amazing!
     
    Thrawn75 likes this.
  24. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    249
    Can the standard cube size be changed? For instance, if they are currently akin to 1x1x1 meter can we change their size if I wanted them to be smaller so theoretically .5x.5x.5 for better detail?

    I'm trying to flesh out my design idea. LOL

    Thanks
     
  25. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Nope. Basic unit is 1x1x1 and shaders, integrated AO and face culling are optimized for that. You can create voxel definitions that use custom meshes, including smaller or bigger geometries (usually for vegetation, trees or other objects), but terrain voxels are 1^3.
     
  26. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    249
    ok thanks :)
     
  27. Tsilliev

    Tsilliev

    Joined:
    Jan 21, 2014
    Posts:
    34
    What caught my eye on this asset is that it has third person AI pathfinding included, imagine all those beautiful terrain generators at the unity store which are all useless because you cant use them to get a guy/enemy from point A to point B. lol.
    I tried the third person demo but:

    1) Is it possible to build a structure out of cubes (minecraft style) and have AI third person walk in it, then out of it? To see that pathfinding works for built structures
    2) From the comments above I saw that the navigation mesh is recalculated for new chunks, I presume if I dig the ground and make a dungeon runtime, the AI will be able to walk around underground?
    3) Is it possible to smooth out the voxels like in Voxeland?
    4) Is it possible to have realistic textures, plants, trees like from Vegetation Studio unity asset?
    5) I saw your youtube video, the water speed filling a hole is a bit fast for my liking, I presume there is a setting to tweak it?

    (I saw a game on Steam called Embark, and I saw some pictures above from futurewavecs that reminded me of the game, maybe they use this asset? I am looking to make a game like that)

    Definitely keeping an eye for a sale.
     
    Last edited: Oct 17, 2019
  28. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Hi,

    1) Yes, NavMesh are generated only for voxel definitions marked as "navigatable" so you can control over which voxels path-finding can work. For instance, you can exclude certain voxel structures like small walls, etc. in order to avoid enemies from climbing them. And they can enter the buildings as long as there's an entrance, sure.

    2) No, although you can define custom voxel types which makes use of a prefab. Custom voxel can use any geometry and be greater or smaller than the standard 1x1x1 voxel. These special voxels are usually used for vegetation, trees, stair steps, decoration, etc. And they can be rendered using GPU instancing so they're very fast as well.

    3) Yes, the asset supports some nice rendering features like parallax and normal mapping, as well as custom voxels which allows you to use a custom shader for specific objects, trees, etc. You can have non-cubic shapes in the world, however, for performance reasons, you should use the provided cubic voxel render types for mass structures, like terrain.

    Regards
     
    Last edited: Oct 20, 2019
    Tsilliev likes this.
  29. Tsilliev

    Tsilliev

    Joined:
    Jan 21, 2014
    Posts:
    34
    Hello, thank you for the answers. I just tried the third person demo again, I build a simple structure and the AI character was able to move to a spot on the structure, although I made him dig a small diagonal 5 block deep cave (like a miner, in a classic minecraft style to go in and get out) although when I told the AI person to go out, clicking on the ground level, it had hard time going back up (running at the direction i clicked at, not going up the natural stairs).
    What kind of pathfinding is used?
    I presume the AI should ignore 2 or more blocks height surface (cave walls), walk only where it can and to follow the exit?
    If you bake the normal unity navmesh on generation of the chunk, attach local nav builder on the character, and add nav source tag on the chunk, that automatically updates its navmesh runtime, it should work?
     
    Last edited: Oct 20, 2019
  30. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Correct. VP produces standard NavMesh upon chunk generation or update. It may integrate the changes in a few frames afterwards though.
    You can check the flat terrain demo scene which uses 3 NavMesh agents on 3 black cylinders pursuing the player. Try destroying / building voxels and the agents will react / modify their routes.
     
    Tsilliev likes this.
  31. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Important: only voxel types with "Navigatable" property set to "True" are considered for NavMesh generation. Most opaque/solid voxels should have this property enabled by default.
     
    Tsilliev likes this.
  32. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Connected textures feature coming in Voxel Play 6!

     
  33. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,511
    Nice anything else? Universal render ? Mirror support? :D
     
    MrG likes this.
  34. Tsilliev

    Tsilliev

    Joined:
    Jan 21, 2014
    Posts:
    34
    Hello, I bought Voxel Play earlier this month and its a great tool, I have a question regarding saving.
    I can save and load the terrain but what about other objects?
    Like a custom character?
    Because I would like to make autosave each minute that saves the terrain and the character.
    1) Where can I find the save function and how to add other objects like the custom character and a gameobject like a workbench to the "objects to save" list? Or I have to create my own saving system for other objects except the terrain?

    I also have a question regarding the digging:
    2) Different kind of ores are generated undergound?

    How can I select a few blocks? I want to save these blocks in a list and have the character walk to each one and dig it.
    3) Where can i find the "GetSelectedBlock" and "DestroyBlock" functions?
    I presume the "PlaceBlock" function is there too? So ican do the opposite - character building/placing a block at a certain spot.
     
    Last edited: Nov 29, 2019
  35. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Hi,

    API reference can be found here: https://kronnect.freshdesk.com/support/solutions/folders/42000013145

    - To save your game use the methods SaveGameBinary(), SaveGameToByteArray() or SaveGameToBase64().
    - To get the currently selected item, use GetSelectedItem() from the Player API.
    - Destroy blocks using RayHit(), VoxelDamage() or VoxelDestroy() methods.
    - Place blocks using VoxelPlace methods.
    - Get the voxel at any position using GetVoxel or GetVoxelIndex methods (there're a lot of similar methods).

    Regarding load/save game, the logic is implemented in VoxelPlayEnvironment.LoadSaveBinary.cs. The current file format is described here.

    You can save additional data in the save game file. All of this is described in this page.

    Regards
     
    Tsilliev likes this.
  36. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    87
    I don't have this asset yet but i was just wondering if it has a way to have the blocks be half height so stuff is more like stairs rather than blocks
     
  37. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    You can have custom voxels which use a prefab. Some houses in the demo scene has a stair that use this kind of voxels.
     
  38. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    87
    I see nice, can you use these custom voxels to generate the regular world, for example so that hills and the terrain itself is more like stairs?
     
  39. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Not currently. You can use them in Models or place them as regular inventory items but not massively.
     
  40. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    87
    Thanks for the info. Is LWRP supported?
     
  41. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    URP will be supported next year, when it stabilises.
     
  42. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    87
    I found something I think might be a bug. If you break a bunch of tiles and don't collect the drops from them, the drops start becoming super tiny, way smaller than the regular size they are supposed to be when they drop out. You can reproduce it in your own minecraft-style demo app. just start it up run forward and break 6 cubes without collecting the drops, and i believe starting from 5, they will all be super small.
     
  43. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Thank you, we’ll check this out and fix that in next beta.
     
  44. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    87
    Just wondering, how exactly are you putting that little building where it teaches you to open doors by pressing T and you go up stairs and see various voxels and whatnot at the starting position and there are also those "Voxel Play" tiles in the ground? Its not a detail generator right, so how are you doing it?
     
  45. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    That demo scene loads a saved map which has that building and the voxels on the ground. Rest of the world is randomly generated by the terrain generator.
     
  46. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    87
    I see thanks for the info. Is there something similar to the constructor but for the world rather than Model? Also where is the loading of that saved map? is it in a script somewhere ?
     
  47. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    Check out this help page: https://kronnect.freshdesk.com/support/solutions/articles/42000041550-loading-saving-game-sessions

    You can edit your world in playmode and save it to a file from the console entering "/save filename". Then you can load it from the console with "/load filename" or using the scripting API described in the online doc.
     
  48. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    87
    ok thanks.
    btw I'm guessing there is no way but is there any mechanism by which you can spawn a limited number of a specific thing across the world ( assuming finite borders )? like for example if you had like 5 items and you want each one to spawn twice in the world, or if you have like 5 towns and you want each one to appear only once in the world. If I understand how these world generation algorithms work, they aren't really linked to other parts of the world so you can set the ratio of how often things appear but you can't set like an exact finite quantity?
     
  49. Thrawn75

    Thrawn75

    Joined:
    Nov 16, 2014
    Posts:
    2,332
    If you use a Detail Generator to spawn your stuff in the world, you can enforce a limit using a counter in your detail generator, so when AddDetail or DoWork methods are called, just increment and check the counter and simply return and do nothing after all instances have been placed.
     
  50. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    87

    Ok I see. I'm guessing this would basically result in the world being different based on where they explore first, and which chunks are generated first, is this correct?

    Also is there a way to set the layer or collider of the little pieces that break off of a block when its destroyed? I'm actually using a custom player controller that uses a rigidbody so those things are actually pushing the player since they have colliders ( I think this is what is called a "Dynamic Voxel" ). I know how to change it in your scripts but was wondering if there is a formal way of changing it.
     
unityunity