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

Resolved Trying to use a "Displacement Map" to imitate water

Discussion in 'Scripting' started by KnoblePersona, Oct 13, 2020.

  1. KnoblePersona

    KnoblePersona

    Joined:
    Oct 13, 2020
    Posts:
    15
    In a [video I watched] about Super Mario Galaxy, this guy talks about something called a "Displacement Map". I can't seem to find anything about it in the context of Unity. The closest thing I could find is Normal Maps, but it doesn't work like he described. The way he puts it, it uses a grey scale map to distort a texture (black pushed to the top left and white bottom right.) By overlapping textures with this, you can make textures appear like water.

    So i guess my questions are, dose unity support something like this, what is a good way to start learning about it, and how do I overlap textures (preferably ones with alpha values)?

    Forgive me if these are simple things, I just started using Unity from using GMS, where i never used shaders or distorted textures, so all of this is vary new to me.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    A "displacement map" could mean anything, but usually it is a bitmap where each pixel contains a value that tells how to distort a vertex or a normal.

    You could use displacement maps in water in a bunch of unrelated ways:

    - to modify a grid of vertices in a mesh every frame

    - to distort vertices by means of a vertex shader

    - to colorize texture with something like a gradient shader

    And I'm sure many other creative ways.

    So yes, Unity can do all these things.

    If you want to water, start by fiddling with some water tutorials or else some water assets off the web or off the asset store, such as this one:

    https://assetstore.unity.com/packages/vfx/shaders/hard-water-70562

    I bought that one and used it in a few of my games but never really looked under its hood, so it might not even do a displacement map, no idea.

    EDIT: linked the wrong thing. Fixed.
     
    KnoblePersona likes this.
  3. KnoblePersona

    KnoblePersona

    Joined:
    Oct 13, 2020
    Posts:
    15
    This is vary useful, and I'll certainly look into this, but I was more talking about texture distorting rather affecting mesh/vertices. It sounds like a dumb thing to do when I have the power to change a mesh to make water look/behave more like real water, but i like the aesthetic of making it look like an old N64/GameCube/Wii game, if that makes sense
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
    Most of Unity's builtin shaders support a texture offset, which you can animate to give the appearance of a "scrolling" or moving surface. Example here:

    Of course Unity also fully supports custom shaders so you can absolutely make a shader that does what you described with a "distortion map". But there's no builtin asset that does that out of the box. You'd have to find such a shader online or write it yourself.
     
    Kurt-Dekker likes this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Just looked at that Mario Galaxy video you linked above... first off, thanks, it's a great video!

    Definitely look into tutorials on water shaders.

    And yes, what Praetor adds above as well... all good water tricks.
     
  6. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,723
    Also I looked at that guy's website and spent about an hour just looking through old game levels. That website is amazing!
     
    Kurt-Dekker likes this.
  7. KnoblePersona

    KnoblePersona

    Joined:
    Oct 13, 2020
    Posts:
    15
    Well it looks like I'm going to have to just learn to make my own then. I've already been looking at tutorials as a start while waiting for replies. I actually watched the scrolling textures video before coming here and it helped. I'll be looking into water shaders specifically when i get a batter grasp of how basic shaders work. Thanks everyone for the help everyone!

    The SMG stuff got me excited to really dive into Unity and his site was super cool to find. I'm happy to see everyone enjoyed it.