Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

World Building Voxel Play - infinite world generator

Discussion in 'Tools In Progress' started by Kronnect, Jan 2, 2018.

  1. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Use the WorldRand static class to get random values linked to world positions so the randomization will be related to the starting seed and will always be repeteable across sessions or peers. For example, WorldRand.GetValue(Vector3 pos) returns a random value that's always the same for a given position.
    In the AddDetail method, you can get a random value linked to the chunk.position field for example.

    The Voxel Layer property of Voxel Play Environment should mandate the layer for the dynamic voxel instances.
     
  2. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    Even if using a random number associated with a position, if you use a counter to limit the number of spawns to a finite amount, it would spawn in the places where that random number matches the spawn condition, when those chunks are loaded first based on where the player goes right?

    So will the voxel layer not affect the regular voxels? In any case, it seems all the dynamic voxels would have to be set to that layer and not just those specific ones.



    Also what is the general concept to use an npc spawner? I saw in the faq how to check for valid places to spawn them but after that, is the idea to use a Voxel Play Behavior with "Chunk Area" set to true? What exactly does this do? Will it be constantly tracking all of these gameObjects and keeping the surrounding voxels existing so the gameobject does not fall through the ground? Is there any alternative recommended method, like I guess I can just check how far these gameObjects are from the player and if they are far enough, just disable them ( which I guess would result in their surrounding voxels to then be unloaded. )
     
    Last edited: Jan 19, 2020
  3. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Then pregenerate the spawn positions during the detail generator initialization so you later only spawn them on those positions.

    Yes, voxel layer property is same for both chunk gameobjects and dynamic instances of individual voxels. Do you need a different layer for dynamic voxels? Maybe post that as a feature request for next update?

    Yes, that component ensures certain area around that gameobject is available (ie. chunks are generated) because, by default, VP only renders chunks in frustum (this depends on the settings but basically your NPC can be far away and you still want them to interact with the voxel world and, among other thing, avoid them from falling down). Not mandatory to use ofc.
     
  4. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    I see thanks that makes sense.

    As for the voxel layer thing, I think a different layer for dynamic voxels is not what the issue is, but rather just that I think maybe there should be an option to make those little voxels that crack out of a voxel when its destroyed to be a different layer so they don't collide with the player. I'm not really sure in what case you'd want the player to collide with those. Maybe its not an issue with your player controller though, I'll have to check later since my controller uses rigidbody and collider movement.
     
  5. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    In Voxel Play Environment inspector, you can define the layer for the crack particles:



    Then, if you use a VP character controller, the asset will automatically force ignore collisions between the Particles Layer set above and the collider of your character.
    In your case, as you're using a different character controller, just use the Layer Collision Matrix under Project Settings / Physics and make sure the character layer is not colliding with the Particles Layer above.
     
  6. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    I see my mistake thanks i thought they were dynamic voxels, didn't realize they were particles.
     
  7. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    If I have a certain voxel spawning with a detail generator, is there a way for me to actually find the voxels? I can't click anything thats generated by the environment script or see them in the object list.

    Also are you going to add support for caves that are not always underwater? It seems right now that everything under a certain level I guess is just underwater?
     
  8. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Try unchecking "Hide Chunk Hierarchy" in Voxel Play inspector. If unchecked, chunks and children objects will be shown in the hierarchy.

    Caves should appear above water as well, but the sample terrain generator currently produces low altitude terrain so most of the time caves will be spawned near water level causing them to be filled with water in most cases. The cave generator uses perlin worms. Given a random starting position, it's starting always on surface so if the surface point is very high with respect to the water level, the cave should not cross the water.
     
  9. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    I see, so is it always intended that there will be a common water level across the whole world? There won't be the case where like there is a body of water and you are in a cave without the water and you break the wall and the water comes in.

    And if you make the world high enough for non-water caves, you wont end up with lakes then?
     
  10. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Please note that the Voxel Engine and the Terrain Generator included are different components. The default terrain generator uses a global water level to determine where water voxels are placed. When it fills a chunk with content, it starts from top to bottom. If the position is empty and it's below water level, it places a water voxel.
    You can of course (that's the point in the end) modify the terrain generator or create a different one (check the online documentation for details).

    If you dig next to the water and cave a tunnel below the water mass, if you break the upper voxels, you will cause the water to poor in down.. another example:


    TL;DR; you can create a terrain generator that places water voxels in the way you want, not only at the same level of water but you could also create lakes on mountains, cascades, etc.
     
  11. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    Thanks, can you tell me where "Hide Chunk Hierarchy" is? Is it in the inspector of the environment, I wasn't able to find it.
    Also can you tell me why when I made a detail generator that places a voxel, some of the tree trunks on some of the trees have dissapeared (leaves are still there). What would cause that ? I would have expected in the worst case that one of the tree trunk voxels would have been replaced.
     
    Last edited: Jan 28, 2020
  12. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Yes, in the inspector, at the bottom of Voxel Generation section:
     
  13. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    Alright thanks.

    can you tell me why when I made a detail generator that places a voxel, some of the tree trunks on some of the trees have dissapeared (leaves are still there). What would cause that ? I would have expected in the worst case that one of the tree trunk voxels would have been replaced.
     
  14. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Could you please send the detail generator by email so we can advice?
     
  15. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    Sorry I sent you a message on here rather than email.
     
    Last edited: Jan 29, 2020
  16. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    I thought I figured it out. I was placing voxels at the position of the chunk with env.VoxelPlace, instead i got the chunk and manually set the voxel to the custom definition and the tree thing was fixed, but now it seems the custom voxels aren't correct, its not executing that script I had on them via the prefab setup.


    *edit I figured out that voxels are only processed (if they are prefabs and have scripts attached to them) when they are actually visible, so not if they are buried. Is this correct? What is the idea for how to make spawners, do they just always have to be at the top of the land, or I suppose maybe be non-opaque and invisible?
     
    Last edited: Jan 29, 2020
  17. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    Hey if I am maintaining data values inside a script on a prefab attached to a custom voxel, will that data be maintained if the voxel gets unloaded and reloaded back?
     
  18. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Chunks can be disabled or unloaded. They get disabled when they exit the visible distance (just hidden). And they get unloaded (destroyed) when the pool is exhausted and chunks need to be reused.
    You can react to that using the events OnChunkExitVisibleDistance/OnChunkEnterVisibleDistance/OnChunkReuse.

    Use the event OnChunkReuse to save your data in memory before the chunk is unloaded.

    Check out the chunk lifecycle page here:
    https://kronnect.freshdesk.com/support/solutions/articles/42000066051-chunk-lifecycle

    Also, when saving a game using the SaveGame APIs, you can also store custom data if you want (or save it on your own using other methods of course):
    https://kronnect.freshdesk.com/a/solutions/articles/42000041550
     
  19. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    Regarding URP support.
    We need this feature so we are thinking about adding it ourselves.
    Are there any gotchas that we should be aware of other than shader conversion (which is relatively easy).
    I.e.
    - Rendering hooks
    - Depth, Frame buffer access (converting from GrabPass, telling the camera to use depth and color buffersetc.)
    - Ensuring SRP batcher works (constant buffers)

    Thanks!
     
  20. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    In addition to that, some uses of Graphics.DrawMeshInstanced (and DrawMeshInstancedIndirect) if you use Voxel Definitions with GPU Instancing option and/or Compute Buffer option in Voxel Play Inspector.
    Those functions should be redesigned as render features.
     
  21. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    That won't take much work, thanks!
    FYI I believe that you can use DrawMeshInstanced and DrawMeshInstancedIndirect with URP now.

    But I haven't tested Indirect
     
  22. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Fun with aerial bombing:
     
  23. pagan_poetry

    pagan_poetry

    Joined:
    Feb 15, 2017
    Posts:
    101
    Is it working on mobile now?
     
  24. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Yes, it has been tested no devices like Galaxy S6 which is quite old now. The device must support Shader Model 3.5 (support of texture arrays).
     
  25. physicsssss

    physicsssss

    Joined:
    Aug 15, 2014
    Posts:
    1
    Is there a way to scale voxelplay objects.. for example the example Village house in voxel play, can we scale it to make it bigger?
     
  26. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    No, but you can make a bigger house in the constructor. Check this link.
     
  27. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875


    Announcing Voxel Play competition for 2020!

    Until October 15th 2020 participate and win $$$. Prizes will be awarded in three categories: Best World, Best Interface and Best Mobs.

    - Best World Award: awarded to the most beautiful, rich and awesome environment created using Voxel Play. Prize: $200.
    - Best Interface Award: awarded to the best design and implementation of in-game UI including inventory, crafting and overall player interactions. Prize: $150.
    - Best Mobs Award: awarded to the best set of animated NPCs, creatures and animated stuff. Prize: $150.




    Competition rules and FAQ here.
     
  28. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Voxel Play 7 now available with Universal Rendering Pipeline support!

     
    tcmeric likes this.
  29. NickM48

    NickM48

    Joined:
    Jan 17, 2017
    Posts:
    5
    Hi, is Voxel Play a suitable base for a game similar in style to Dwarf Fortress, where you have automated people that you give tasks to, such as cut down that tree to get a wood resource etc.?

    I can see that it is great at being a Minecraft type game but wondered whether it would work well as a game that is viewed from high above.

    Many thanks
    Nick
     
  30. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Here's an aerial example:


    You can use a first, third person or any kind of perspective you want. Most projects use first person perspective because if you dig into the terrain, it's easier to interact with surrounding terrain when making tunnels, caves, etc.
    When using a third person view and if you enable the "See-Through" option, the view looks like this:


    btw, here're some cool devlogs using Voxel Play at Coherence site:
    https://www.coherence.io/blog/creative-spotlight/fronterra-devlog-01/

    More on our Discord channel.

    Cheers!
     
  31. NickM48

    NickM48

    Joined:
    Jan 17, 2017
    Posts:
    5
    Thanks for the very quick reply.

    I have another question, sorry.

    Would it be possible to hide layers, for instance, hide all layers above zero or hide all layers above -5?
     
  32. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Not currently but could be added in a future update.
     
  33. NickM48

    NickM48

    Joined:
    Jan 17, 2017
    Posts:
    5
    Is it something that I could add for my own use?

    Many thanks
    Nick
     
  34. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    You could ofc - it requires a couple of changes. First of all, the meshing algorithm (greedy mesher) has to be tweaked so voxels are not combined vertically so when you cut at certain altitude, you can see the top faces of those voxels (imagine a 3x3 set of blocks which the asset usually optimizes as one big block to reduce vertex count now you cut it in half, since the upper face is above the cut line, you would see the interior of that box which is undesirable). And then, shaders need to discard pixels above given altitude (or if you're not changing very often this cut height, you can just ignore any voxel above the given altitude during the meshing stage).
     
  35. NickM48

    NickM48

    Joined:
    Jan 17, 2017
    Posts:
    5
    Thanks for all of your help, you have a new customer :)
     
    Kronnect likes this.
  36. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Thanks. I'd recommend joining the Discord, so questions can also be discussed with other members as well.
    Cheers!
     
    NickM48 likes this.
  37. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    NotaNaN, digiross and SweatyChair like this.
  38. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Hi all!
    Happy to announce a new tutorial serie about implementing multi-player in Voxel Play using Mirror.
    Check them out:



     
  39. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    Is there a demo for Mobile?
     
  40. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    There're some demos although none for mobile. VP has many quality settings that you can use to adapt it to your requirements from fast, simple effects to more complex fx. It works fine on mobile as long as it supports texture arrays and you use a reasonable view distance for the device.
     
  41. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    It would be nice to see a mobile build of the asset. I think it would be a good selling point but that's my thoughts. Thank you for the reply.
     
  42. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Two Android builds are now available for the first demo scene:
    https://kronnect.com/support/index.php/topic,2779.0.html
     
  43. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
  44. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
  45. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    236
    I see. Is it possible to change the texture arrays to something else that would work?
     
  46. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    No, it’s not trivial as the asset uses that feature extensively for all rendering aspects of voxels.
     
  47. Patrick-Goettert

    Patrick-Goettert

    Joined:
    Jun 25, 2014
    Posts:
    2
    Hello!
    I bought the asset a couple of weeks ago and I am extremely happy with it!
    I definitely recommend it!


    edit: I noticed that when you walk away too far from the origin (say 30,000 units) the floating pointing error gets very noticeable and everything starts getting shaky. Any chance to implement a "Floating Origin" solution? I would be glad to help doing so.
     
    Last edited: Feb 14, 2021
  48. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Hi,
    This could be a memory issue. Try lowering the chunk distance and also enable the “Low Memory Mode”? https://kronnect.freshdesk.com/support/solutions/articles/42000001705-system-requirements
    We’ll check this and look for further improvements for mobile.
    I recommend you to join our Discord server as we have a very involved community and some tips may be shared there as well.
    Regards
     
    Last edited: Feb 14, 2021
  49. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Hi all!

    Interested in learning how to create multiplayer games using Mirror and Voxel Play? Check out our latest game template, Pirates of Voxel Play. Includes all resources to learn by example how to make multiplayer games using these two awesome frameworks. Check it out:

    Pirates of Voxel Play!
     
    P3ndragonLLC likes this.
  50. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,875
    Voxel Play 9 is out!

    This update features 64 bit internals to account for large worlds and an origin shift solution right into the engine.
    Now you can create worlds up to 1.000 km in extents with no performance loss! (larger worlds in the future will be possible as well if needed).
     
    P3ndragonLLC likes this.