Search Unity

Smooth tile transitions (procedurally generated terrain)

Discussion in 'Scripting' started by Thegusse, Apr 18, 2014.

  1. Thegusse

    Thegusse

    Joined:
    Nov 29, 2012
    Posts:
    49
    Hello.

    While messing around with some top-down procedurally generated terrain in 2D I've run into a problem: I simply can't figure out how to achieve smooth tile transitions between the biome edges. I realize that there are many ways to do this, but at this point im purely looking for the easiest solution. It could just be a slight blur along the edges like in Rim World.

    I guess I'm looking for some sort of alpha blending or something, but how would I do that with the 2D-shader? Besides that, one solution could possibly be to make a complete tileset for all the possible combinations, but I imagine that turning into a hell when trying to place the tiles properly.

    Thanks!
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    This depends heavily on how you're building the terrain in the first place. It's probably not possible with the 2D shader, since that expects everything (color and alpha) in the same shader.

    If this was me, I would ignore the 2D/Sprite shader, use a self-illuminating-alpha-blend shader, and construct my own mesh…. but then I'm good at generating meshes, and this might not be the best option for you.

    Performance-wise (and probably simplicity-wise), photoshopping edge tiles for every edge combination is going to be your best bet. Any other solution is going to involve alpha blending textures and a fair amount of overdraw.

    So, the question is, how do you build your world?
     
  3. Thegusse

    Thegusse

    Joined:
    Nov 29, 2012
    Posts:
    49
    Hey, thanks for the quick response.

    The world data is currently being generated using perlin noise. I then place different tiles according to the different height values.

    So if I go with the method of creating tiles for the edge combinations, I guess I would need some kind of system to detect the neighrbour-tiles and then place the edges according to those. How would I avoid this turning into a giant mess of if-sentences that I end up losing control of?
     
  4. Thegusse

    Thegusse

    Joined:
    Nov 29, 2012
    Posts:
    49
  5. Thegusse

    Thegusse

    Joined:
    Nov 29, 2012
    Posts:
    49
    Last bump - no one has experience with this?
     
  6. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I don't think there's any getting around a bunch of if statements.
     
  7. Fy-

    Fy-

    Joined:
    Sep 29, 2016
    Posts:
    9
  8. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    200
  9. Fy-

    Fy-

    Joined:
    Sep 29, 2016
    Posts:
    9
    Duende likes this.
  10. theforgot3n1

    theforgot3n1

    Joined:
    Sep 26, 2018
    Posts:
    205
    these links are leading me to some suspicious places, Fy.
    I advise others against following them.