Search Unity

Question How to blur layers in 2D?

Discussion in '2D' started by jtsmith1287, May 11, 2023.

  1. jtsmith1287

    jtsmith1287

    Joined:
    Aug 3, 2014
    Posts:
    787
    I'm experimenting with a Dwarf Fortress style game. First time doing anything like this. To create the map I have a Tilemap for each layer, and I use a perlin noise heightmap I generate randomly to determine which textures go where. If you scroll the mousewheel you move the camera in or out 1 unit. Each tilemap is separated by 1 unit of space. I want to blur each visible layer below the active one and have each layer blurrier the further down it is. I tried using a depth of field effect, but duh, it's an orthographic camera lol. I am considering now creating a transparent plane for each layer that's fixed to the camera. I could put a blur shader on each layer and as I zoom out the layers will overlap and progressively blur the scene. But that means if I have 32 layers (which I do, and I eventually want more), I need 32 blurred planes. And that just seems dumb. Any ideas?

    Here are some screenshots to explain. Here's the terrain from the Scene View.
    upload_2023-5-11_13-19-50.png

    Here's the terrain from the player's view zoomed *all the way out*.
    upload_2023-5-11_13-20-58.png

    Outside of your knowledge of geology/topology, you can't tell what the elevation is of the tiles you can see. Now I'll zoom in a little on this same spot. The dark gray areas are obstructed areas, as in, underground.

    Here's zoomed in a few layers.
    upload_2023-5-11_13-22-36.png

    So the main goal is make it obvious which layer is the active layer. Any clever ideas there and I'm all ears. But in my mind the best result would be a blur to give a sense of distance -- so only the active layer is clear.

    I'm going to start working on the layered blur thing because I don't have any other ideas right now, but I feel strongly it won't be the final solution.

    Thanks!
     
  2. jtsmith1287

    jtsmith1287

    Joined:
    Aug 3, 2014
    Posts:
    787
    Wowee! Forget that mess, haha. So many sorting order issues with sorting layers. That will be a nightmare to handle. Shucks. Well hopefully someone has some ideas on this lol!
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    What do you mean by blur, like a bokeh effect? You can do that with a shader and there are examples to pull off github and also assets you can buy in the Asset Store.
     
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    MaxwellTan and Kurt-Dekker like this.