Search Unity

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

Combining (adding) textures

Discussion in 'World Building' started by Thimble2600, Jun 5, 2019.

  1. Thimble2600

    Thimble2600

    Joined:
    Nov 27, 2015
    Posts:
    165
    My game has a bunch of tile types (dirt, grass, forest, farm, water, sand, tundra etc...)

    Each tile is given a height value which determines its type.
    Each tile observes its neighbour's types to determine its rule.
    The resulting string of <type> + <rule> gives the sprite name.
    This result is passed to a SpriteLoader which returns the sprite UV coordinates in the texture.

    Each tile texture only contains its own type, so grass will only contain grass, dirt will only contain dirt.
    This means that when you meet a corner or edge tile of a type there's nothing rendering underneath the transparent part of the edge/corner tile.



    To get around this I could have each tile type stored in its own layer, but that would be incredibly impractical as there would be some (15 types * between 9 and 12 chunks loaded, each containing 50x50 tiles) 900,000 triangles loaded at any one time.

    It'd be ideal if I could find a way to render more than 1 texture in a tile.

    upload_2019-6-5_15-51-25.png + upload_2019-6-5_15-45-23.png = upload_2019-6-5_15-53-5.png

    I don't suppose anyone could offer some advice. I'm really hoping to achieve something like Warcraft3's terrain layer system.

     

    Attached Files:

  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Hmm. It wouldn't be so bad if you could sort your types into one of only several layers. E.g., dirt, road surface, caked mud, would all be in the bottom layer; then things that grow on top of this, like any sort of grass, would be in a layer above. Then you can put any grass/shrubbery/etc. on top of any sort of underlying terrain, and it looks great.

    You do of course still have to deal with transition tiles, where dirt gives way to caked mud etc. I think this is the crux of the issue, isn't it?

    In that case, you either have transition tiles in your tileset for all possible transitions (I think this is the standard solution), or you double up on your triangles only for those places where a transition is happening. Or, you make a shader that lets you draw two textures at once, a foreground and a background texture. All of these amount to basically having two layers, but being more clever about what goes in which layer than basing it on type — instead, "edge tiles" would always go in the top layer, and "solid tiles" would always go in the bottom layer (auto-selecting these based on the neighboring tile type, perhaps).
     
    Thimble2600 likes this.
  3. Thimble2600

    Thimble2600

    Joined:
    Nov 27, 2015
    Posts:
    165
    Ye, this is what I'm thinking I'll end up doing. Thought I'd best ask first though. Cheers mate ;)
     
    JoeStrout likes this.