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 :

Limbo water shader

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 !

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.

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.

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).

You might be interested in our 2d water material: Water 2D Kit | 2D Water | Unity Asset Store - 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.