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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

2D Voxel Terrain

Discussion in '2D' started by Unexpected_Persona, Aug 14, 2015.

  1. Unexpected_Persona

    Unexpected_Persona

    Joined:
    Jul 23, 2015
    Posts:
    9
    I am interested in making a 2-dimensional game with destructible terrain, but first I'd prefer to learn all I'll need to know in order to build the terrain and allow proper interaction between entities and the terrain. Unfortunately, all of the resources I've found are either vague or designed for 3-dimensions, and I'm not sure if converting it into two dimensions would be the most efficient option and I don't really know how to do UV meshes for rendering. I'm looking for advice on how to proceed.
    Thank you for your help.
     
  2. kuchaku

    kuchaku

    Joined:
    Oct 14, 2014
    Posts:
    37
    In a lot of ways I'm in the same boat. Although I"m aware what I'd be creating in Unity wouldn't true voxels like Ken Silverman's Voxlap or medical scanners, but probably just polygonal meshes, surely there would be best practice for dealing with adjustable meshes, with adjustable textures and a minimal performance impact?

    I'm sure you're ware of this tutorial here which stays 2D, if I recall correctly until the 4th entry and could at least give you some idea of the meshes ( seem to have a memory of 1 draw call per UV however):

    http://forum.unity3d.com/threads/tutorial-procedural-meshes-and-voxel-terrain-c.198651/

    You might also choose to go the route of marching cubes, which is fascinating here( catlike coding has great tutorials by the way):

    http://catlikecoding.com/unity/tutorials/

    Anyway, I'd be very interested in best practices for keeping batching, for efficient geometry, UVs, while keeping minimal draw calls, minimum materials. But to tell you the truth, if people figure this out it will probably just go on the asset store. That's probably my love/hate relationship with Unity. It's part of what makes it feasibly affordable for Unity as the assets are profitable for them too. And assets can be convenient, but honestly, it's my impression that it also discourages the free sharing of information that fosters learning in some of the other communities I've witnessed.

    That said, I'm not sure I've seen an asset that quite meets your requirements either. If you're planning on going sprite based some of the tilemaps may or may not need your needs (some are slow for changing at runtime or can't handle a large number of tiles). I don't know which one is the best for procedural purposes, nor have I seen any benchmarks. under a heavy procedural load, it would be helpful for people interested. Unity is planning its own tilemap, but I've heard no word of runtime alteration performance.

    But if you're going for polygonal 2D, I'd probably go the route of trying the marching cubes algorithm as it looks really flexible and could produce diverse and intriguing results. You could likely protrude the model out backwards and use that as collision information as well. If you could combine the marching cubes with this tutorial which is also quite nice:

    http://forum.unity3d.com/threads/procedural-cave-generation.296986/#post-2213331

    I have a feeling I'm going to spend the next year or so, trying as many tutorials on as broad of a spectrum as possible and reading everything I can probably for the 3D aspects. Lots of fumbling around, experimenting and trying to figure out the best practices myself. I think this might be your situation as well the situation quite a few people might be in. A good portion of what is learned will likely be sold on the asset store, with assets that may or may not meet your needs, or may or may not be very helpful for you. I'm hoping whatever I learn, I can share.