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. Dismiss Notice

Question 2D top-down water shoreline foam effect

Discussion in 'Shader Graph' started by ArianB, Oct 25, 2020.

  1. ArianB

    ArianB

    Joined:
    Mar 12, 2018
    Posts:
    8
    Hey,

    I have a procedural top-down island generation system in 2D and I've been trying to figure out how to create a water shoreline shader for something like this, as i've only come across ways to achieve this in 3D using camera distance and so on. I'm looking to achieve this in 2D for a top down island. Here is an example of my island:
    myisland.PNG
    The effect i'm trying to achieve:
    island example water.jpg

    Maybe it's possible to use an animated sprite shape that surrounds the island?
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Instead of pure shader solution, have you thought about using rule tiles if you are using Unity's tilemap system? I think you could use rule tiles to make shape that follows the shoreline.
     
  3. ArianB

    ArianB

    Joined:
    Mar 12, 2018
    Posts:
    8
    Yes I've thought about that, but the issue is that I need them animated and for some reason I can't use animated tiles in a generated island, it only let's me hand paint them. I was looking for something more dynamic and modular, but haven't come across anything yet
     
  4. HCollier

    HCollier

    Joined:
    Sep 26, 2018
    Posts:
    1
    I am also looking to create an effect like this, without the use of RuleTiles. However, seeing as you have said that you would settle with using Animated RuleTiles as a solution, you can actually use animated tiles in your generation. Just pass the Tilemap into the script and when you loop through your noise array, you can just do this:
    Code (CSharp):
    1. Vector3Int position = new Vector3Int(x - (width / 2), y - (height / 2), 0);
    2.  
    3. // Code to determine which tile you should place, in this instance I will just use the keyword PlacingTile.
    4.  
    5. // Place the tile in the tilemap.
    6. Tilemap.SetTile(position, PlacingTile);
    Hope this helps! :)