How it works...

The core that this shader uses is a grab pass to take what has already been rendered on the screen. The part where the distortion takes place is in the Fragment function. Here, a normal map is unpacked and used to offset the UV data of the grab texture:

half4 bump = tex2D(_BumpMap, i.texcoord);half2 distortion = UnpackNormal(bump).rg;i.uvgrab.xy += distortion * _Magnitude;

The _Magnitude slider is used to determine how strong the effect is:

Get Unity 2018 Shaders and Effects Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.