How it works...

As mentioned previously, this shader works by showing only the silhouette of an object. If we look at the object from another angle, its outline will change. Geometrically speaking, the edges of a model are all those triangles whose normal direction is orthogonal (90 degrees) to the current view direction. The Input structure declares these parameters, worldNormal and viewDir, respectively.

The problem of understanding when two vectors are orthogonal can be solved using _DotProduct. This is an operator that takes two vectors and returns zero if they are orthogonal. We use _DotProduct to determine how close to zero the _DotProduct has to be for the triangle to fade completely.

The second aspect that is used in this shader 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.