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

[Water] How to: Create a Coastline / Waves around objects (images attached)

Discussion in 'Shaders' started by StreakyFox, Sep 9, 2014.

  1. StreakyFox

    StreakyFox

    Joined:
    Jan 23, 2014
    Posts:
    2
    Iam trying to figure out of the following effect is done:



    My conclusion so faar:
    1. Blue water texture applied to mesh
    2. Shader or Script calculates collisions between water mesh and other collision objects
    3. White waves (second texture?) are rendered somehow along the collision points.

    Could someone hint me into the right direction how the white waves are done?
     
  2. gyh

    gyh

    Joined:
    Aug 6, 2015
    Posts:
    5
    Hi,Have you got the perfect answer?
     
  3. gyh

    gyh

    Joined:
    Aug 6, 2015
    Posts:
    5
    Now,I want to creat a game with terrain and the coastline,but i don't have a perfect plugin with it ,can you give some advice for me.Thank you ! Best wishes~
     
  4. Duusty

    Duusty

    Joined:
    May 14, 2013
    Posts:
    56
    Hey there. I dont know how much knowledge you have about shaders. But here is a quick advise how you could achieve this effect.

    First create a 1D texture, defining the waves (so you'll draw the amount of them, the thickness, the space between).

    Then inside the shader for your water surface, you will need access to the depth/z buffer, to calculate the coastline. Normalize the Depth Variation into a Range from 0-1. And use this value as UV coordinate for your 1D Wave texture. Then you should probably add depending on the world position or vertex color. Some Variation (You could multiply and offset the uv of your 1D Texture with a Cosinus/Sinus Wave)

    Thats all it should need for coastline :)

    You could probably also add a normal map that offsets your depth value for a bit more variation.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    The way Nintendo does those kinds of effects is they model all of that stuff in manually. They're panning textures on manually modeled geometry that floats just above the water plane.