Search Unity

Creating a nice tile map a la RimWorld

Discussion in '2D' started by BlisterFingers, Jul 29, 2016.

  1. BlisterFingers

    BlisterFingers

    Joined:
    Sep 2, 2015
    Posts:
    11
    There's a lot of things to love and try to understand about RimWorld but the thing that's really got me thinking lately is the tile map. Now there are a few posts around about tile maps but I haven't found anything that really sheds any light so if anyone can I'd be very greatful.

    Some things I don't understand/want to know:
    • Rimworld's tiles don't have a single texture that repeats on every tile of the same type. They appear to use larger textures that are spread accross multiple tiles (if not all tiles of the same type in the map). How is this achieved?
    • Rimworld's tile textures blend and merge together. They have a soft transition where dirt and stone meet, for example. Is it using special textures that cover every possible transition or some other technique?
    • There is no tearing/seams between the tiles in the tile map. RimWorld still suffers from this a little with it's wall tiles but the floor/ground tiles don't have any of this. Is this because of the previous thing?
    Personally I've implemented a very simple tile map. A custom mesh with 4 verts and 2 tris per tile, using the UVs to select various tiles from my tile atlas texture. This works but has issues with seams unless the tile images in the atlas are padded and doesn't address the blurring/merging or the textures spread across multiple tiles.

    I'm here asking for insight as I really don't know how to move forward on this so any help would be appreciated.

    Thanks.
     
  2. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    3,957
  3. BlisterFingers

    BlisterFingers

    Joined:
    Sep 2, 2015
    Posts:
    11
    You're right. That doesn't answer my question. xD

    I've seen the series, though. I wouldn't reccomend it, personally.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,208
    You can use multiple variations of a tile, distributed randomly, which gives the appearance of a larger, non-repeating texture; there are four different tiles here in a 4x4 grid:

    tile2.png

    For transitions, you can use alpha transparency and two layers, where the top layer contains tiles with transparency and the bottom layer shows through the transparent parts. This allows smooth transitions without having to make every possible combination of transition tiles:

    tile1.png

    --Eric
     
  5. BlisterFingers

    BlisterFingers

    Joined:
    Sep 2, 2015
    Posts:
    11
    Hello Eric, thanks for your post.

    The transitions you specify seem simple enough, though I think I would want a custom shader to do the transitions based on an alpha mask rather than using 5x the texture space for each tile type. This gives me lots of avenues for exploration, thanks.

    The multiple variations approach would be a simple way to do it, however RimWorld doesn't appear to do this as much as use much larger textures and use the tile information to figure out where to render them, tiling them on a much larger scale. Check out the sand dunes in this image. I'd really like to understand how that's done.

    My uneducated guess for how it's done would mean creating or at least UVing parts of the mesh seperately such as the following example.

    example2.jpg

    Imagine each pixel is a tile in our tile map. The far left image shows the whole map then the other three are water, dirt and sand sections all seperated out. Now rather than applying the UVs to each tile seperately, we take each section and apply UV to it as a whole, repeating the texture not just on every tile but at any scale we wish.

    I'm not 100% on how to make this work yet but it's all I've got.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,208
    I think you misunderstood. The idea is that you use a single tile with alpha for the transition, with another layer underneath for other tiles. This saves a great deal of texture space, rather than using more, and you don't need custom shaders. The image I posted has a single tile repeated 4 times, with another layer underneath with several different tiles. That is, a layer of tiles, not layers in Photoshop or whatever.

    tile3.png

    It could simply be larger tiles, or larger images sliced into smaller tiles.

    --Eric
     
    Deleted User and BlisterFingers like this.
  7. BlisterFingers

    BlisterFingers

    Joined:
    Sep 2, 2015
    Posts:
    11
    I believe I understand just fine but unless I'm mistaken, if you're image can't be easily rotated (better shown by the grass texture in your examples) you'll need five tiles. 1 normal tile and 1 each for each direction the transition could be in. Hence 5x the texture space.

    example3.jpg
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,208
    That's true, but in many cases you do actually want to have individually created tiles for transitions, and indeed may even want multiple tiles for each direction, since a plain alpha blend can be too bland. Particularly if the tiles have some element of perspective to them.

    --Eric
     
    BlisterFingers and Martin_H like this.
  9. papa_schllumpf

    papa_schllumpf

    Joined:
    Nov 10, 2013
    Posts:
    1
    If you say something like that, be more specific on whys!
     
  10. Gmotagi

    Gmotagi

    Joined:
    Jul 27, 2013
    Posts:
    13
    This may help for the tile map. I think to get the good transitions though a customer shader will be the way to go, especially if you have lots of different terrain types. For simple maps though you can do it this way.

    http://www.angryfishstudios.com/2011/04/adventures-in-bitmasking/

    Re: that tutorial, I don't think its that bad, the biggest problem though (from what I've seen of it) is that he is using individual gameobjects for each tile which is going to grind to a halt when the map gets to any 'RimWorld' size map.
     
  11. J0hn4n

    J0hn4n

    Joined:
    May 11, 2015
    Posts:
    24
    That tutorial its more than enought to start hes render and logic its separated, so you can use 3d models if you want and doesnt going to have impact on the game. if you are wondering abount size maps i have to say you dont need render all the map , just render what can be see, so separe your map into chunks.
     
  12. plumphelmet

    plumphelmet

    Joined:
    Apr 18, 2013
    Posts:
    8
    We wrote about this, you may find this helpful.

    You need to have textures that span multiple quads, Rimworld uses 16x16 64px (1024px) textures, and you also need to smooth the edges.

    Hope this helps: http://www.plumphelmet.com/post/edge-smoothing
     
  13. Fy-

    Fy-

    Joined:
    Sep 29, 2016
    Posts:
    10
unityunity