Code Monkey home page Code Monkey logo

unity-water-shader2d's Introduction

Unity 2D Water Shader

Add a nice refraction water shader to your game!

Checkout the video:

Youtube Demo Video

Usage

Try it

Just clone or download the repository and open the folder within Unity.

Run the included Demo Scene.

Use it within your Game

  • Put the DisplacementBehaviour and DisplacementShader into your game. Keep the shader under Resources folder.

  • Attach the DisplacementBehaviour to your main camera and set up a noise and water texture as behaviour property (the sample ships with sample textures).

  • Limit the water effect to a certain scene area by adding planes to the built-in Water layer.

  • You can specify the turbulence (waviness) of the water by setting the Turbulence property of the DisplacementBehaviour. The turbulence will also influence the strength of refraction.

Implement Scrolling

When the camera scrolls left or right, the water waves need to change their phase offset. Otherwise they will appear to be a "camera overlay" flying over the scene.

The DisplacementBehaviour has a scroll offset parameter which can be incremented / decremented on scrolling.

Check out the included CamScrollBehaviour as a reference implementation for scrolling.

What's next

  • Physical Collision Behaviour (Ripples)

  • Better Effects (I'm experimenting ;) )

  • Better Demo Scene

Disclaimer

I am pretty new to shader programming, so the source may not be optimal. Contributions are welcome! :) I tested the shader on Windows, Mac OS, iPad Pro 9.7 and iPhone 7.

Implementation

I am currently writing a tutorial about the details. Stay tuned :)

Contact

Feel free to contact me if you have any questions. In case you are going to use this shader within some application, I'd be happy to hear about :)

Follow me on Twitter: twitter.com/mbue_coding

unity-water-shader2d's People

Contributors

real-marco-b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

unity-water-shader2d's Issues

Android version

Hi,
this is really good shader!
can you make it work in android?
I think that _screenCam.SetTargetBuffers(_screenTex.colorBuffer, _screenTex.depthBuffer);
doesn't work on that platform :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.