- Home /
2D Water Shader
I am trying to build a 2D Water shader and I am using Unity 4.
Here is an example of what I am trying to reproduce :
Are there any good tutorial or whitepaper about creating such effect blur and displacement ? I am not talking about waves or something but only the depth of the water.
Is it a Camera shader or an object shader ?
Thanks a lot !
Answer by MaT227 · May 16, 2013 at 08:45 AM
I have Unity Pro. I saw that the best way to achieve such effect is to use Grabpass in the shader. But there are two problems with this system :
It seems that Grabpass is quite heavy for mobile as said here Using Grabpass & IOS/Android devices . But as I am learning shader, I don't know any other system to create refraction.
There is an issue with foreground objects, they are refracted too. There is a solution here GPU Gems - Refractions . But is this solution available ?
Another interesting link : Unite 11 - Shadowgun The fluid part is at about 30:00.
Answer by tanoshimi · Feb 19, 2016 at 10:24 AM
Not sure why this question has resurfaced on the front page of UA but, for the sake of anyone viewing this in 2016, I thought I'd point out that RenderTextures have been a free feature available in all versions of Unity since 5.x. In fact, there's a standard asset water shader included in Unity that'll give you a textured water plane with reflections, surface waves etc. just fine with either 2d or 3d scenes, and from there it's fairly trivial to add blur/displacement etc., so you might want to start with that.
However, I think that water shader looks rather plain when viewed from above. It also looks nothing like the water in Limbo. On the other hand, the water in Limbo doesn't look special anyway :)
Answer by Ferb · Sep 30, 2014 at 05:02 PM
With Unity Pro, a simple method would be to have your main camera draw the screen to a RenderTexture. Then you can take that texture and perform whatever extra effects you like on it before finally drawing it to the screen - blur it, displace it, swirl it, whatever. If you have Pro, and you want to do a blur on a texture you've already drawn the screen to, just look up Gaussian blur, it's quite a simple technique - basically averaging the colour across a few surrounding pixels.
But with Unity Free, the only method I can think of would be to draw your objects distorted in the first place. That means if any object is in the water, you'd have to give it a special material, with a special shader, that draws it with the blur or whatever other distortion you want. And it would be complicated even more by the fact that an object might only be partially in the water, so your shader would probably have to accept a second texture that tells it which parts to draw distorted, and update that texture each frame (although Unity Free doesn't have RenderTextures that can be drawn to by the camera, it has procedural textures which can be edited with SetPixels).
Answer by ravingbots · Feb 09, 2016 at 10:00 AM
You might be interested in our 2d water material: http://u3d.as/o75 - it has animated waves, a refractive (glass) shader, some splash FX with sounds, and an example of buoyancy physics. It uses the grabpass method and works on mobile devices. It does not require Unity Pro and can be used with the Personal Edition.
Your answer
Follow this Question
Related Questions
Standard Asset water material is pink 4 Answers
Why is my Pro Water Material Grey? 1 Answer
How to create this top down water effect using spriteshape? 2 Answers
Material doesn't have a color property '_Color' 4 Answers
Water Shaders Question 1 Answer