Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/real-marco-b/unity-water-shader2d
A 2D water shader for Unity
https://github.com/real-marco-b/unity-water-shader2d
refraction shader unity3d water
Last synced: 2 months ago
JSON representation
A 2D water shader for Unity
- Host: GitHub
- URL: https://github.com/real-marco-b/unity-water-shader2d
- Owner: real-marco-b
- License: mit
- Created: 2017-03-10T16:18:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-03T15:04:48.000Z (over 6 years ago)
- Last Synced: 2024-08-02T05:13:10.206Z (6 months ago)
- Topics: refraction, shader, unity3d, water
- Language: C#
- Size: 304 KB
- Stars: 102
- Watchers: 5
- Forks: 19
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-unity-open-source-on-github - unity-water-shader2d - A 2D water shader (Water)
README
# Unity 2D Water Shader
Add a nice refraction water shader to your game!
Checkout the video:
[![Youtube Demo Video](https://img.youtube.com/vi/M-sK7hOlYnE/1.jpg)](https://www.youtube.com/watch?v=M-sK7hOlYnE)
## 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](https://twitter.com/mbue_coding)