Search Unity

Voxeland - Voxel Terrain Tool

Discussion in 'Assets and Asset Store' started by Wright, Jun 25, 2013.

  1. Darkmalice

    Darkmalice

    Joined:
    Apr 6, 2018
    Posts:
    4
    I'm having an issue with trying to instantiate a voxeland prefab (Static) on a host-client. The prefab looks fine in inspector but once it's spawned in the scene the chunks are all missing their meshes (along with a couple of other things like the brush highlight material).
    Is there a particular way to do this that I'm missing?

    I'm using:

    Code (CSharp):
    1. GameObject voxeland = Instantiate(voxelandPrefab, transform.position, transform.rotation);
    2.         voxeland.name = voxelandPrefab.name;
    3.         NetworkServer.Spawn(voxeland);
    Missing mesh example:
    badchunk.PNG
     
  2. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    309
    I'm finding plenty of information available on using Megasplat with Voxeland, but nothing regarding Microsplat. Any idea on if this is possible?
     
  3. JasonCG

    JasonCG

    Joined:
    Oct 6, 2012
    Posts:
    29
    I don't have a project handy at the moment to test this out, but something like this should work. If the object gets spawned a lot though it won't perform very well. Perhaps in that case change the _voxeland variable to static.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. /// <summary>
    4. /// jasoncg
    5. /// </summary>
    6. public class TerrainExplosion : MonoBehaviour {
    7.  
    8.     [SerializeField]
    9.     private Voxeland5.Voxeland _voxeland;
    10.     public Voxeland5.Voxeland voxeland {
    11.         get {
    12.            if(_voxeland==null) {
    13.                 _voxeland = GameObject.FindObjectOfType<Voxeland5.Voxeland>();
    14.            }
    15.            return _voxeland;
    16.         }
    17.     }
    18.  
    19.     [SerializeField]
    20.     private bool explodePosition = true;
    21.  
    22.     public int setLandType = 0;
    23.  
    24.     private Voxeland5.CoordDir coord = new Voxeland5.CoordDir();
    25.     private Voxeland5.Brush brush = new Voxeland5.Brush();
    26.  
    27.     /// <summary>
    28.     /// Convert world coordinates to Voxeland integer coordinates
    29.     /// </summary>
    30.     /// <param name="voxeland"></param>
    31.     /// <param name="position"></param>
    32.     /// <returns></returns>
    33.     public static Vector3Int WorldToVoxeland(Voxeland5.Voxeland voxeland, Vector3 position) {
    34.         var resultf = position;
    35.         //Just in case Voxeland is not at origin or is scaled, handle that here
    36.         resultf -= voxeland.transform.position;
    37.         resultf.x /= voxeland.transform.localScale.x;
    38.         resultf.y /= voxeland.transform.localScale.y;
    39.         resultf.z /= voxeland.transform.localScale.z;
    40.      
    41.         var result = new Vector3Int(Mathf.FloorToInt(resultf.x),
    42.             Mathf.FloorToInt(resultf.y),
    43.             Mathf.FloorToInt(resultf.z));
    44.  
    45.         return result;
    46.     }
    47.  
    48.     void OnEnable() {
    49.         //If Voxeland wasn't already set, try to set it now
    50.         if (voxeland == null)
    51.             voxeland = FindObjectOfType<Voxeland5.Voxeland>();
    52.  
    53.         if (explodePosition)
    54.             ExplodeHere();
    55.         else
    56.             SetLandHere();
    57.     }
    58.     /// <summary>
    59.     /// Remove Voxeland terrain at the given center world coordinate,
    60.     /// and radius
    61.     /// </summary>
    62.     /// <param name="center"></param>
    63.     /// <param name="radius"></param>
    64.     public void Explode(Vector3 center, int radius) {
    65.         var voxelCoords = WorldToVoxeland(voxeland, center);
    66.         coord.x = voxelCoords.x;
    67.         coord.y = voxelCoords.y;
    68.         coord.z = voxelCoords.z;
    69.  
    70.         brush.form = Voxeland5.Brush.Form.volume;
    71.         brush.extent = radius;
    72.         voxeland.Alter(coord, brush, Voxeland5.Voxeland.EditMode.dig, 0, -1, -1);
    73.     }
    74.     public void SetLand(Vector3 center, int radius, int landType) {
    75.         var voxelCoords = WorldToVoxeland(voxeland, center);
    76.         coord.x = voxelCoords.x;
    77.         coord.y = voxelCoords.y;
    78.         coord.z = voxelCoords.z;
    79.  
    80.         brush.form = Voxeland5.Brush.Form.volume;
    81.         brush.extent = radius;
    82.         voxeland.Alter(coord, brush, Voxeland5.Voxeland.EditMode.add, landType, -1, -1);
    83.     }
    84.     /// <summary>
    85.     /// Calls explode treating this object as a sphere
    86.     /// </summary>
    87.     public void ExplodeHere() {
    88.         Explode(transform.position, (int)transform.localScale.x);
    89.     }
    90.     public void SetLandHere() {
    91.         SetLand(transform.position, (int)transform.localScale.x, setLandType);
    92.     }
    93. }
    94.  
     
    FrostedBrain likes this.
  4. Tsilliev

    Tsilliev

    Joined:
    Jan 21, 2014
    Posts:
    35
    Anyone had luck with realtime navmesh update using the instruction that I quoted from Xype?
    Specifically when destroying/building new voxels?
    Surprised this asset doesn't have one, how is anyone using AI enemies/animals to walk around?
    I saw on the earlier pages that A* was mentioned, but the price looks really big when there is a free alternative like unity navmesh.
     
  5. EnriquePage91

    EnriquePage91

    Joined:
    Jul 2, 2015
    Posts:
    67
    Hi Dennis,

    I am trying to utilize MapMagic in conjunction with Voxeland but I am having issues again on Unity 2019.9f1.

    For some reason, VoxelandEditor.CS is pointing out that all of the three classes do not have a definition for "voxeland".

    The error number for all three compile errors is: CS0117

    The classes are the following:
    1 - VoxelandOutput
    2 - VoxelandGrassOutput
    3 - VoxelandObjectsOutput


    I love both of your plugins, especially together and in conjunction with Vegetation Studio Pro (btw, I got them to run together at a certain point a few months ago so it certainly is doable although some coding will probably be required).
    Unfortunately, as long as this issue isn't fixed I am forced to delete Voxeland for the moment (I don't know how long it would take for me to figure out what the issue is, from quickly exploring the classes the errors are pointing out, and checking the VoxelandEditor script, I don't think it'll be a little time so I'd rather wait for your feedback).

    It would be very appreciated if you could let me know whether this is an issue on your side, perhaps related to my version of Unity, or something like that.

    I have noticed that Voxeland hasn't been updated in over a year, so perhaps it's just because MapMagic has changed and in recent versions you've taken apart such Voxeland functionality perhaps?? I also noticed that many Voxeland lines of code were commented on the scripts that I just brought up, and I even saw a remark of you which explicitly said ""WTF this doesn't work!?!?!?!", and when I saw this I realized that I could try to make sense of them all but it just seems like an overkill when I could simply ask you first, perhaps you are in the process of fixing an issue introduced by the newer versions of Unity, or something like that.

    Please let me know, as if this is the case and an update to Voxeland might take still a while, then I might have to figure out how to fix it myself and in that scenario any help you could provide would be deeply appreciated.

    Thank you for your patience and support,

    Enrique.
     
    Last edited: Oct 30, 2019
    patchworkx and WildStyle69 like this.
  6. zrocweb

    zrocweb

    Joined:
    Dec 19, 2016
    Posts:
    43
    Has anyone had any success getting voxeland to serialize over the net. I'm using PUN2, room based, which is what my game will take on for initial release, 6-10 players per room. Any guidance would be most appreciative. I have a network view setup on the main voxeland gameobject and components are being copied to each chunk. Unfortunately I don't think the docs code/rpc suggestions are going to work. Might for a small terrain (300-600 units), but not for anything larger. Anyhow. every time a player terra-forms and the RPC is invoked, the other players become either invisible to the player who just terra-formed or become non-existent to the same player, still that player's camera view, meaning the other player(s) who were not terra-forming can no longer be shot at for instance and the player who terra-formed just sees them. Or like I send they disappear completely from the player camera who just terra-formed.

    HELP

    NVM. Fixed it.
     
    Last edited: Nov 13, 2019
  7. patchworkx

    patchworkx

    Joined:
    Nov 8, 2014
    Posts:
    20
     

    Attached Files:

  8. zrocweb

    zrocweb

    Joined:
    Dec 19, 2016
    Posts:
    43
    Did you activate compatibility for both voxeland and map magic via Window/Map Magic/Compatibility. Make sure both voxeland and map magic are checked
     
  9. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    309
    For what it's worth, I've had the same issue with current release Voxeland not being able to recognize the current release MapMagic. It has worked well for me in the past, but hasn't worked right for me in a couple months. I've checked both tools and checked the relevant boxes I could find, to no avail. Tried using Unity 2017.4.x and 2018.4.x on Mac.

    I've got a question regarding the Texture Array Inspector (available separately in Asset Store as well as included in Voxeland). Is there a way to set per-platform resolution settings on the arrays?

    Normally with terrain textures, I use per-platform overrides to set high texture resolution for desktop, then reduce to lower resolution for iOS, Android, and web. This way, when a build is compiled (or in my case, content uploaded to a Unity-based virtual world for processing), the resolution settings are respected and resulting file sizes are lower and load times much shorter. Since I have not been able to set an override, I wind up with mobile and web build sizes that wind up being bigger than desktop region file sizes (not sure how that happens).

    Any help would be appreciated.
     
  10. zrocweb

    zrocweb

    Joined:
    Dec 19, 2016
    Posts:
    43
    Hmm.. Curious. Did you try to just import MapMagic, Voxeland into a new project and enable compatibility. You might have a conflict with something else. Also check your current projects DEFINES. Something is missing. I've used both for years now and have never had an issue with this. Have gone from Unity version 5.5 up through 2019.
     
  11. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    309
    Yes - clean project, import each. I saw mention of a scripting define that needs to be set up in project settings/player in the MMWG thread, when I get a chance between current projects I'll give that a go. My guess is that the import is failing to add that, and if I manually enter it then things might work.
     
  12. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    Megasplat is for mesh terrains, Microsplat is for Unity Terrains.
     
  13. cwxxc3

    cwxxc3

    Joined:
    Feb 1, 2017
    Posts:
    23
    @Wright I've been playing with the demo and have some questions before I consider purchasing:

    1) Is there a way to have a fixed space so it doesn't automatically generate when you walk closer the edge of a map
    2) When you dig down can you have different textures instead of stone, say metal ore or sand. or layers where the top of the terrain has dirt, then stone then bedrock
    3) Can this asset have multiplayer added easily without issue or will it be a hassle? I saw some posts earlier in the thread were you said it's possible for multiplayer but has anyone done it yet?
    4) will this be on sale for the winter sale?
     
  14. zrocweb

    zrocweb

    Joined:
    Dec 19, 2016
    Posts:
    43
    Yes use the modes and ranges. The demo is pretty much set up well in that it shows this. However the demo is also a static terrain, so there is nothing really generating. To see what I'm referring to, change the demo from Static to Dynamic Limited for Runtime. Might want to increase the overall terrain size a little too. If you can't see the terrain generating as your players camera (or demo camera) get within range take of horizon setting and you will see it easier.

    Yes, this is done via the layers and preferably using Map Magic with it as it's generator.

    Yes it can and because Voxeland and with Map Magic is already a streaming asset, it makes it even easier. I have successfully added multiplayer functionality, real-time, with Voxeland, MapMagic and Multi-Player.[/QUOTE]
     
    Mienja likes this.
  15. WildStyle69

    WildStyle69

    Joined:
    Jul 20, 2016
    Posts:
    318
    What available options are there for lighting setup with Voxeland - at the moment it seems that only real-time lights can work. So there is no support for baked probes or anything else?

    // WildStyle
     
    Mienja likes this.
  16. Mienja

    Mienja

    Joined:
    Jan 15, 2013
    Posts:
    3
    "Free evaluation version: a fully functional version with two limitations:
    - the legal one: it could not be used in a final product. Please purchase the full version before releasing your game.
    - the code one: most of the settings from the settings and generate tabs are locked to default and could not be changed."

    For one, where is this free evaluation version now? I have paid for Voxeland as it is a great tool, but I noticed that the free evaluation link no longer points to anything except an error page.

    Also, there used to be a way to custom choose how large the chunk would be. What happened to that? You would set up how high and how deep before generating. I am now confused how to have control over that. Any help would be greatly appreciated! Sometimes I need a VERY small chunk of Voxeland clay, 37x77 for instance.

    Is this the only community/forum page for Voxeland or is there some other place for discussions available?
     
  17. zrocweb

    zrocweb

    Joined:
    Dec 19, 2016
    Posts:
    43
    My guess is that Dennis took it offline as it was probably being pirated.

    You can choose whatever size terrain you want via the 'Modes and Ranges' section of the Voxeland Component. As for the size of the voxel this is something you would have to do via code.
     
  18. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,278
    Seem to be still working fine: http://www.denispahunov.ru/voxeland/eval.html
    Must be a typo on the first page. Fixed. Thanks for finding that out!

    Do you really mean chunk - or the Voxeland terrain as a whole? If the second one - try setting the size the way zrocweb mentioned. Chunk is the internal entity that shouldn't be exposed, like the patch in the standard Unity terrain.

    Don't know about the community, but it's the only official Voxeland thread. Is there something wrong about it?
     
  19. Mienja

    Mienja

    Joined:
    Jan 15, 2013
    Posts:
    3
    Thanks for fixing the link!

    The old setting I remember using was the one you entered custom numbers instead of just using the default setting. This was done before generating them. Some are so small they only use one chunk piece, haha! I figured these settings would now be under the "Generate" header in the Inspector. Just not sure how to get what I want by using this. i will look into the zrocweb link. Thanks


    This works fine! Just wondered if there were any other community groups. Thanks for the speedy response!
     
    Wright likes this.
  20. Mienja

    Mienja

    Joined:
    Jan 15, 2013
    Posts:
    3
    Thanks so much! I will try this right away!
     
  21. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    question. after I have made a voxeland area look the way I want it to with the MM visual scripting window.. How do I output that as a biome data file?
     
  22. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,278
    Biome files are the same as the graph itself. If you have stored it in assets (with the Store To Assets button in Generate tab) you can assign it as a biome.
     
  23. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Using 2020.1.0a14 ( I know alpha.. ) I need to manually press rebuild every time i load a scene otherwise no chunks are generated. Also happens in build and play mode where it's easily fixed by calling rebuild in script.
    Any idea what could've changed in 2020 to cause this?
     
  24. mrs26

    mrs26

    Joined:
    Sep 13, 2018
    Posts:
    12
    Hey Denis,

    I'm wondering whether or when there will be SRP support in Voxeland any time soon.

    I know this question has been asked before. But that was over a year ago so maybe the answer has changed.
    (If there are more recent posts about this topic I apologize for overseeing them)
    That time you said:

    As for now I think that things have settled down. LWRP is already out of preview and so the HDRP will be soon. The standard built-in pipeline might or might not become depreceated from there on. Either way I think it's worth to invest time into this feature.

    If you're not planning to implement this any time soon, I'm thinking of configuring a shader that works with the new pipelines myself. However, I'm not that much experienced with shaders. What I couldn't quite figure out in your current implementation is how your shader determines the correct texture for the correct block type. Since the terrain of a chunk is one mesh, how does the shader now for each pixel, which block type/texture would be at that position? You somehow have to query that information to it, right? If you couldCan you give me a hint on how you do that?


    Also btw, do you have any ideas to another problem, which I described right here: https://gitlab.com/denispahunov/voxeland/issues/186
    I'm experiencing this issue on 2019.1.11f1, but I think it's the same on other versions.

    Thanks in advance^^
     
    Last edited: Nov 30, 2019
  25. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    I am having a problem getting grass to show up at all on voxeland using MM..... can anyone help out?

    here are screenshots of both my heightmap setup, and my grass setup im MM using voxeland..... but I cannot get the grass to show. I have tried multiple different ways to output to the voxeland grass, but it doesn't seem to want to work. any help on this subject?

    I'm aware the end of the grass group is incorrect, and meant for MM only, but I can't find any way to get it to work with voxeland....... have tried removing the MM grass...... and replacing it with voxeland grass genrator.......... but there is no mask input on a voxeland generator so I'm missing a whole input for the grass, and for the life of me grass will not show up at all yet.

    thanks








    for instance, this does not produce any grass at all either........... and it should shouldn't it?

     
    Last edited: Nov 30, 2019
  26. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    any help at all with getting grass to show up with voxeland using MM graph's?
     
  27. mrs26

    mrs26

    Joined:
    Sep 13, 2018
    Posts:
    12
    So, I got a shader working with the mesh channel encoding set on RTP. Sadly, only after I composed my follow up post xD But first one simple question on the RTP mode:
    You said it doesn't use any encoding. Does that mean I it only supports 5 textures?

    (1, 0, 0, 0) -> tex1
    (0, 1, 0, 0) -> tex2
    (0, 0, 1, 0) -> tex3
    (0, 0, 0, 1) -> tex4
    (and any new block type would apply tex5, because the 1 would be in the next, channel which doesn't exist, so the result would always be (0, 0, 0, 0)

    If that's the case, and until now it seems to me that it is, I'd rather like to get my shader working using the Voxeland mode. The one that uses UVs. Because with the encoding you use there I can use 32 different textures, right?

    So here the post I already composed before figuring out the RTP mode, which addresses the problems I encountered using the voyeland encoding:

    I started implementing a shader. In your documentation and in another post of yours you state that voxeland is using the UV channels to transfer the information of which texture to use at which vertex to the shader. Since you use a triplanar projection this makes sense. So using shader graph I accessed the UV channels via the UV Node, which gives you the option to choose from UV0, UV1, UV2 and UV3. Each one of them has 4 channels (RGBA). So what I expected was that in one or some of these UVs there would be different values in the channels for different block types. However, no matter which block type, all values of all UVs remained unchanged (UV0 - UV2 were filled with (0, 0, 0, 1). UV3 was filled with (0, 1, 0, 1), but also didn't change across different block types).

    Interestingly that values instead changed on another condition. I don't know what exactly the condition is, though. If you look at the picture below, it looks like it's working and the couple of blocks on the foot of this "tower" have a different block type. But that's not the case. They have the same block type as the surrounding blocks and the UV change there occured when building up that tower. Once I remove that tower, the UV of the blocks below changes back to normal. When I dig a hole into the terrain, the UV inside that hole changes too.


    Also, you mentioned in your post before that using the UV to transfer this information, you have 32 channels for the textures. Or what you probably mean, with the 4 UV channels you can differentiate between 32 different textures.
    The easiest approach to use the UV channels I can think of would be a binary encoding. If each channel represents a bit that can either be 0 or 1. But that would only give you 16 different textures/block types. So I guess you're using a different encoding. The thing is, even if you use a different encoding, the content of the UV channels should still be different for each block type. But as I mentioned before, I get the same values for every block type... Instead the UV changes under some other unknown condition..

    Obviously, I am missing something. I just don't know what.
     
  28. DenisPahunov

    DenisPahunov

    Joined:
    Dec 2, 2019
    Posts:
    4
    I'm thinking of creating a universal shader graph so that land material would be compatible with any render pipeline. However, Voxeland shader relies heavily on vertex data. Like vertex colors, custom vert tangents, etc. At glance I don't see a way to do this with the graph, but I'm not a big expert in shader graphs (at least yet) so I might be missing something. Anyways I've got to finish MM2 first before implementing this so do not expect it in the next month for sure.

    Speaking of the issue reported - I will look into it as soon as I can. Unlike shader graph it's not a new feature, so try to fix it asap

    Edit: sorry, missed your post while typing. Yes, rtp encoding (via colors) is not actually an encoding. Just blend weights for 5 first channels, all others are disregarded. I don't remember exactly if I'm still using uvs for voxeland encoding or switched it to tangents channel, but the thing is that I'm storing just 2 bytes for channel, this way there are only 16 possible blend grades. And I'm not using any advanced stuff like converting to int and bitshift - just not sure all platforms support it. The approach is pretty straightforward with multiplying and adding.

    Wrote back via email but will try to report the progress in case someone else get this issue.
     
    Last edited: Dec 2, 2019
  29. mrs26

    mrs26

    Joined:
    Sep 13, 2018
    Posts:
    12
    Would be much appreciated^^ it doesn't have to be in the next month of course, but it's nice hearing that there are plans or thoughts about it. If you'd find the time to do it within the next year though it'd be great.

    Thanks, this issue has been driving me crazy.

    no worries^^

    I see.. indeed, looking into your code (ChunkMesh.cs, EncodeChWeights()) I noticed you're filling a tangents array with some values that you're calculating. I thought this code is for something different since I thought the texture mapping is done via UVs. Now I'm pretty sure this function is exactly the part where the job is done.

    Still I don't quite understand yet what exactly the calculation does and where exactly the values land in the end, and in what format. Already tried playing around with tangents in shader graph but it didn't seem to do anything and also i was thinking isn't a tangent supposed to be always the right angle to the normals? I mean, how can you overwrite this data for texture mapping, doesn't that break something? I will look into the code again soon, to try to understand it. But if you can remember what exactly you did there I'd be happy if you could explain it to me.

    In general I would highly recommed you to do more documentation, both in code and in your online docs.
    I love Voxeland and there is nothing on the assetstore atm that I would consider an alternative. I already tried uTerrains, which is great, too. But I don't like how you manipulate the mesh directly when you dig. It often produces sharp edges that just look terrible. Voxeland can look so smooth, that you almost don't see that it's actually a made of voxels. However, the editing is still "controlled". You can mark exactly the one voxel you want to remove or add and the mesh just updates and still looks great. I just love it. But sometimes it's really bothersome to work with it and integrate your own features with it. Since the code is quite complex and there's almost zero documention about how it works.
     
  30. mrs26

    mrs26

    Joined:
    Sep 13, 2018
    Posts:
    12
    Okay, I think I kinda get the tangent encoding now.

    So at a given vertex, each texture has an amount/weight. You scale this weight from 0 to 15, so it can be represented in 4 bits. Floats have 32 bits in C# , but you seem to only use the first 24. Maybe the float type that is used in the shader only has 24 bits, idk. However, that means you store the weights of 6 textures in one float and a tangent Vector has 4 floats. So in total you can store 24 texture weights.

    Decoding this in shader graph seems quite complex, but since you can write Custom nodes, you could put the decoding for the floats there. So this seems doable. The only problem is that the tangent vector node in shader graph only gives you 3 floats. That is probably because Unity expects the w value to be always 1 for general tangents, and -1 for binormal tangents (https://docs.unity3d.com/ScriptReference/Mesh-tangents.html). And there is actually another shader graph node which is called bitangent vector. So probably because of that distinction the w value is just dropped.
    But this only means that the number of supported textures is decreased to 18. That's still much better than 5. So I will try to write a custom node that will decode the tangents. I just hope that the information that you put in there can really be fetched by this tangent node..

    I will keep you up-to-date on that. Maybe once you have time to look into this you could try if it also works with a float32 to have more textures. And maybe instead of storing the information in the tangents, why not store it inside the vertex colors like you do for RTP, just instead of having one float for one texture apply your encoding on that. The vertex node in shader graph gives you access to all 4 values and since I already tested it with the RTP mode I can tell you it works.
     
    Last edited: Dec 2, 2019
  31. mrs26

    mrs26

    Joined:
    Sep 13, 2018
    Posts:
    12
    So I wrote the Decode Node:

    Code (CSharp):
    1. {
    2. //actually only 4 bits needed
    3. uint mask1 = 15;
    4. uint mask2 = mask1 << 4;
    5. uint mask3 = mask2 << 4;
    6. uint mask4 = mask3 << 4;
    7. uint mask5 = mask4 << 4;
    8. uint mask6 = mask5 << 4;
    9.  
    10. uint scaledMix = (uint) Mix;
    11.  
    12. Weight1 = ((float)(scaledMix & mask1)) / 15.0f;
    13. Weight2 = ((float)((scaledMix & mask2) >> 4))/ 15.0f;
    14. Weight3 = ((float)((scaledMix & mask3) >> 8))/ 15.0f;
    15. Weight4 = ((float)((scaledMix & mask4) >> 12))/ 15.0f;
    16. Weight5 = ((float)((scaledMix & mask5) >> 16))/ 15.0f;
    17. Weight6 = ((float)((scaledMix & mask6) >> 20))/ 15.0f;
    18. }

    However, after writing and testing it, I realized that the tangents are being normalized before they are queued into the tangent node in shader graph. And this cannot be undone, since we don't know what the original max values were. The max value varies depending on which nibles are being set during encoding. If we knew which ones that are, there'd be no need for the decoding obviously. So I took your encoding code, duplicated it and changed it so it would store the values in the vertex color instead of the tangents. queued that into my decoding node aaand... it kinda worked. As you can see in the picture the vertices where one texture has a weight of 1 and all others 0 it looks fine. But the transitions look really weird.
    I spend some time with trial and error and thought a lot about what could be causing this and how to solve it.
    I had many ideas but none of them seem to be it.

    So for now, I went back to a simpler approach. Just like the RTP mode I take the values and just store one texture weight per channel. Just instead of using the vertex colors I am using 4 UVs. With this I can apply 16 different textures. For now that's fine but if you compare to games like minecraft, 16 different block types... that's actually nothing. MegaSplat for example can apply 256 textures on one mesh/terrain. I saw you have an integration for that, too. Haven't looked into it yet though. But I think it also uses the UVs. I saw that they are stored in an array of undefined length. So it should be possible to create more than 4 UVs. But the UV node in shader graph only gives you access to the first 4. I bet in a custom shader I could probably access all of them, though. So I think this is the way to go.
     
  32. Murble

    Murble

    Joined:
    Aug 7, 2019
    Posts:
    14
    So, very new with MapMagic and Voxeland and don't know much. I've been looking at the demo for MapMagic and incorporated that into Voxeland which is why this will seem familiar. However, when I added caves as done in the MapMagic + Voxeland tutorial I noticed weird stretching from the vertices. {83822259-3314-4E10-861C-F8A3151FD519}.png.jpg
    It's almost like the surface of the terrain is trying to blend with the caves below it. The MapMagic nodes are very similar to the MapMagic demo as I'm using those to learn MapMagic.
    {0DD4CE4D-28F7-4FF5-92B0-66CDE19541B3}.png.jpg
    Is it a setting on the Voxeland? The only settings I changed on the Voxeland gameobject is the Relax and the Mesh margin. I did read that changing those can smooth the terrain, but can cause artifacts. Is this that? How can I fix it without changing the smoothness then. Other than these stringy bits I like the terrain as is.
     
  33. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,278
    Unfortunately could not reproduce this issue. Seems to be related with the heightmap you are using, since it doesn't show any weird behavior neither in default terrain nor in demo scene. And undo seems to be working. It might be exceeding the maximum number of verts by chunk - but there should be an error in the console in this case (and possibly it breaks everything preventing from undo). Could you please attach or email me the scene with the broken terrain?

    This issue looks similarly to the mentioned one. However your version of the broken scene could be handy too. Could you please email it to me?
     
  34. FrostedBrain

    FrostedBrain

    Joined:
    Sep 26, 2019
    Posts:
    31
    Thanks for the help so far

    I am getting this error when pasting your code

    "
    Severity Code Description Project File Line Suppression State
    Error CS0200 Property or indexer 'TerrainExplosion.voxeland' cannot be assigned to -- it is read only Assembly-CSharp D:\xxx\xx\xx2020 SplitScreen\Assets\TerrainExplosion.cs 57 Active
    "
     

    Attached Files:

    Last edited: Dec 19, 2019
  35. cwxxc3

    cwxxc3

    Joined:
    Feb 1, 2017
    Posts:
    23
    Well I purchased it but I'm having trouble getting multiplayer to smoothly. I followed the offical docs and my local players send commands they hit this spot and then they get an RPC back but it's incredibly slow and causes lag/freeze when it generates. I tried rebuild() but it doesn't work. Any tips on how you did it would be appreciated.
     
  36. Loths

    Loths

    Joined:
    Aug 18, 2017
    Posts:
    9
    Hey, I just picked up Voxeland and playing around with it I can't seem to get the brush tool to work or do anything. From what I can tell from videos of people using it, I assume it's just a matter of selecting the Voxeland object in the outliner and then clicking on the terrain? If so, in my case it only selects whatever chunk is under the mouse as is usual Unity behaviour. No errors in the console. Is this a compatibility issue? I'm on 2019.3.0f3.
     
  37. Deleted User

    Deleted User

    Guest

    Hey, I have 3 Questions:

    Is it possible to create a mesh out of one Voxeland Chunk with textures and UVs on it at runtime? EDIT: Currently just notice one chunk is already one mesh... great

    I used Voxeland like 1 year ago with the Map Magic integration, as now MM2 comes out would it also support Voxeland as well?

    Voxeland is now up for some years now are you planning to create a new Voxeland as you did with Map Magic 2?

    EDIT: LWRP or better Universal Render Pipeline as it's called in 2020, Is there support for LWRP aka URP on the way?

    Happy new year by the way :)
     
    Last edited by a moderator: Jan 1, 2020
  38. mrs26

    mrs26

    Joined:
    Sep 13, 2018
    Posts:
    12
    Hey there,

    I just recently asked the same question. Here's Denis' reply:
    If you want to use Voxeland in URP or HDRP sooner, I made a Voxeland shadergraph that supports 16 block types at the moment. If you provide me your email address I can send it to you, plus the code adjustment I needed to add.
     
    Wright likes this.
  39. Deleted User

    Deleted User

    Guest


    Ow that's great I keep it in mind :)
    Currently, we are waiting for Map Magic 2 so at the moment there is no need to rush it and If there is a URP support on the way we could just wait and work instead in the Legacy Renderer and when Voxeland come out with URP we doing the switch, because our game is far away from the release state :)
     
    mrs26 likes this.
  40. Asmardian

    Asmardian

    Joined:
    Sep 12, 2019
    Posts:
    3
    Greetings,

    I am trying to alter the Voxeland terrain so that it can use a single Unity built-in material instead of texture arrays (since the HDRP supports shader graphs, so I think I'll use that instead of texture arrays). So I simply created a new material and applied it to both the Land and the Horizon in the materials tab, and the problem is that the material does not work on Horizon chunks (even though it does work on the Land chunks).
    Specifically, after I applied the material, the Horizon simply disappears and turns into a plane, illustrated as below

    I think I definitely missed something, and I tried but failed to figure out what is wrong (I am a beginner in shaders and forgive me if this is a silly question).

    Looking forward for your reply!
     
  41. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,278
    It's hard to say what's wrong without seeing the code. One of the possible reasons is sending RPC each time the terrain changes, event if it's changed with RPC, creating an infinite loop. How big is that lag?

    Everything seems to be working fine in 2019.2. Downloading 2019.3 to have a look.
    EDIT: seems to be working fine in 2019.3. Is this issue happening in a demo scene or new scene? Is Lock Selection is enabled in Voxeland object - Settings?

    Yes, I have some great plans on next generation of Voxeland. MM2 compatibility should be here too, not sure I'll implement it in current Voxeland - at least on MM2 release. However, I have not even started it since I'm going to finish MM2 first.

    I've fiddled with the graph a bit, and came to conclusion that it's possibilities are rather limited. For now I came to the crossroad, and have to decide what to use - either shader graph or standard shaders. Hope Unity will improve it's functionality over time.
    But I guess the community (as well as myself) would be grateful if you could share your work, or even publish it at the Asset Store.

    Horizon uses vertex displacement, this way it's not re-generating mesh each time player position changes. Theoretically it could be done with the shader graph, but I haven't tryied doing this myself. You can find the algorithms in the land shader under the _HORIZON defines.
     
    Last edited: Jan 15, 2020
    Deleted User likes this.
  42. Loths

    Loths

    Joined:
    Aug 18, 2017
    Posts:
    9
    Tried with Lock Selection both on and off, no luck. This is in the demo scene, but also happens in a fresh scene, all in an otherwise fresh project. Am I just missing some way of activating the brush tool? Unity just behaves the same as with any other object select.
     
  43. Deleted User

    Deleted User

    Guest

    Did you try to change the Unity Layout to Default?
    Editor tools sometimes only work with the Default Layout, same with Edit Colliders for example...
     
    Wright likes this.
  44. Caliber-Mengsk

    Caliber-Mengsk

    Joined:
    Mar 24, 2010
    Posts:
    689
    I'm probably just missing something, but how do you get a currently existing voxel's type and id?
    It's most likely cause it's super late at night and I got up really early and am missing something. I don't see anything in the documentation and google searches and glancing through this post, I don't see a way to get that information.

    Pretty much I'm wanting to do the simple thing of digging up a block and adding it to the player's inventory. I've gotten the voxel as CoordDir, but I can't find any way to get this information with that object or the Voxeland Object even with having the voxel coords from the CoordDir. I'm super tired so I wouldn't doubt I'm missing something, but I just don't see it. T_T I just want to add dirt to my player object's inventory T_T

    (Perhaps this information could be added to the documentation?)
     
  45. Caliber-Mengsk

    Caliber-Mengsk

    Joined:
    Mar 24, 2010
    Posts:
    689
    Nevermind. My super late night programming failed me and I see it in the documentation -_-
     
  46. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,278
    So, have you tried resetting the layout? Does it help, or do you need me to look into it?

    Just in case someone other will run into this problem once in a dead of night: Editing Voxeland terrain with scripts
     
  47. Caliber-Mengsk

    Caliber-Mengsk

    Joined:
    Mar 24, 2010
    Posts:
    689
    I am having a slight problem that I'm not sure there's a fix for. Is there a way to change the relax strength/iteration of individual voxels? Pretty much I was intending to use the object type voxel as a way to do crisp edges while keeping the terrain as smooth. The problem is where those two types meet up. (See attached photo)

    If not, is there any known fix for this kind of problem? Not only is the visual just not great looking, but you get caught on the edge when walking over it.
     

    Attached Files:

  48. mrs26

    mrs26

    Joined:
    Sep 13, 2018
    Posts:
    12
    Hmm, I'm not quite sure what you mean about that, but what I did is add a new option for the Mesh Channel Encoding. Just like the user can choose between Voxeland, RTP or MegaSplat, there would be an option where the block type data will be stored in the UVs. Then you just need to set a material for the blocks, that reads from the UVs. This can be a normal shader or a shader graph. There should actually be no problem in providing both and let the user select the one he/she wants to use.

    The only limitation that I came across is that in shader graph (as for now) you have only access to UV0, UV1, UV2 and UV3. With each of them being a Vector4 for each vertex, without any encoding this leaves us with only 16 different block types that can be supported. However, if I remember correctly, I only tried using your encoding algorithm on the tangents array and on the vertex color. Both of them were normalized or scaled before scheduled to the shader graph so that didn't work, but maybe it will work on the UVs...
    I'll look into this when I've finished writing my master thesis.

    I would like to share it with all of you. Since it's just an extension to Voxeland I don't think it'd be wise to publish it in another asset. I think it'd be great instead if you could integrate these things in Voxeland directly. That way I wouldn't have to redo all the adjustments everytime I update it^^

    So for the code extensions, they are in Voxeland.cs, Chunk.cs and ChunkMesh.cs.

    Voxeland.cs:

    Code (CSharp):
    1. public enum ChannelEncoding { Voxeland, RTP, MegaSplat, NinjaScarsUV};
    at line 80.

    Chunk.cs:
    Code (CSharp):
    1.             else if (voxeland.channelEncoding == Voxeland.ChannelEncoding.NinjaScarsUV)
    2.             {
    3.                 float[] chWeights = new float[verts.Length];
    4.                 hiWrapper.uvs4 = new List<Vector4>[4];
    5.                 for (int i = 0; i < hiWrapper.uvs4.Length; i++)
    6.                 {
    7.                     hiWrapper.uvs4[i] = new List<Vector4>();
    8.                     for (int j = 0; j < hiWrapper.verts.Length; j++)
    9.                     {
    10.                         hiWrapper.uvs4[i].Add(new Vector4());
    11.                     }
    12.                 }
    13.                 for (int ch = 0; ch < maxChannelsCount; ch++)
    14.                 {
    15.                     if (!ChunkMesh.IsChannelUsed(faces, ch)) continue;
    16.                     ChunkMesh.FillChWeights(faces, verts, ch, ref chWeights);
    17.                     ChunkMesh.EncodeUVChWeights(chWeights, ch, ref hiWrapper.uvs4);
    18.                 }
    19.                 List<Vector4>[] loUVs = new List<Vector4>[4];
    20.                 for (int i = 0; i < 4; i++)
    21.                     loUVs[i] = hiWrapper.uvs4[i].GetRange(0, loWrapper.verts.Length);
    22.                 loWrapper.uvs4 = loUVs;
    23.             }
    24.  
    at line 526.

    ChunkMesh.cs:

    Code (CSharp):
    1.         public static void EncodeUVChWeights(float[] vertChWeights, int chNum, ref List<Vector4>[] uvs)
    2.         {
    3.             for (int v = 0; v < vertChWeights.Length; v++)
    4.             {
    5.                 float fval = vertChWeights[v];
    6.                 List<Vector4> uv = uvs[chNum / 4];
    7.                 Vector4 vec = uv[v];
    8.                 switch (chNum % 4)
    9.                 {
    10.                     //note adding Data.minLandType
    11.                     case 0: vec.x = fval; break;
    12.                     case 1: vec.y = fval; break;
    13.                     case 2: vec.z = fval; break;
    14.                     case 3: vec.w = fval; break;
    15.                 }
    16.                 uv[v] = vec;
    17.             }
    18.         }
    19.  
    at line 1302.

    As for the shader graph, it's not yet complete, as it ignores the M (map) value of specular and gloss.
    It uses the diffuse texture and normal map and uses the Height value as strength for the normal map (I think that was the intention). From the general material options only the Blend Crispness is regarded. Tiling, ambient occlusion, etc. is all ignored too for now. Adding all these things shouldn't be a problem, but it's a bit bothersome since it takes some time to configure it all. So I until I finished my thesis I won't work on this, too.

    Also notice that the shader graph only works in version 2019.3 (HDRP). I tried importing it in older versions but it was not compatible. I haven't tried using it in a LWRP or universal project. But I hope it will also work for them as wlel as for future releases.

    The archive contains the main shader graph called Voxeland UV, as well as some Sub Graphs that the main graph uses.
     

    Attached Files:

    Last edited: Mar 10, 2020
    P_Jong, Deleted User and ibbybn like this.
  49. ibbybn

    ibbybn

    Joined:
    Jan 6, 2017
    Posts:
    193
    Very nice mrs26!
    In the process of changing my whole project to HDRP and this gives me some hope.
    Seems to work well when creating a new terrain directly with your encoding. Tried without success to change my megasplat voxel assets to this but doesn't seem to work even after changing to no texture array and rebuilding etc.
    Will test some more. Thx for the great starting point!
     
  50. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    When working with voxeland is it best practice to only have one instance of the asset? By this I mean, would I be able to treat voxeland as if it were unity terrains, where I could import different instances into a scene. If that still doesnt make sense, say I have a mountain and a hill and I want to put both in a scene at different locations. Would I need to have both the mountain and the hill together in one voxeland instance or could I import multiple voxeland instances into the same scene without causing a headache?