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

How to Make a Dynamic Water Shader that Reacts to Rigidbodies

Discussion in 'General Graphics' started by robert-nally, Sep 1, 2019.

  1. robert-nally

    robert-nally

    Joined:
    Mar 5, 2014
    Posts:
    76
    Does anyone know how to make a dynamic water shader that reacts to rigidbodies?

    One exists for UE4 and can be found here as an example.

    Campo Santo developer Matt Wilde has also written about how he made one for their new game here. I've gone through the blog a number of times and I tried to read through and understand a white paper on the subject that he links to, but it's a little thick at 177 pages and the material itself is pretty dense and difficult to fully comprehend let alone imitate.

    So I was wondering if anyone here had some simpler explanations or experience trying to implement something like this. I'm not even a 100% sure where or how I would start to try to replicate it. I absolutely love the look of it though and I'd love to try to get it working to some extent and put it into the game I'm working on.
     
  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    Last edited: Sep 2, 2019
  3. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,255
    @mouurusai I'll thank you for this since the op just ignored your help. o_O

    I'm going to try and set this up in my project & I'm trying to understand the setup.

    Do I add the water surface shader to a plane and the water rings to a custom particle effect? Should it then work?

    Thanks again.
     
  4. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,255
    @mouurusai It seems what you shared is missing the bump shader?
     
  5. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    derkoi likes this.
  6. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,255
    Thank you!
     
  7. robert-nally

    robert-nally

    Joined:
    Mar 5, 2014
    Posts:
    76
    @mouurusai Thanks for the help. I didn't quite understand your answer at the time and I had to look further into things.

    I'm not using one of the scriptable render pipelines in my project at the moment so I don't have Shader Graph there so I couldn't really try out what you had posted. I also don't have a material editor or shader writer like Amplify Shader Editor in the project either.

    I ended up going with a much more basic approach to get water ripples. I just put a trigger around my water body, and then I instantiate a water ring prefab particle effect on the player when the player enters the trigger. I used an empty game object to get the Y value for where the water ring should always be on the water. The X and Z value come from the player. When the player exits the water I parent the prefab back to the water body so it stays in the water where the player jumped out.