How to do it...

To create this effect, start by modifying the duplicated shader:

  1. Let's start by adding a property to our shader, which will be used to modulate its extrusion. The range presented here goes from -0.0001 to 0.0001, but you might have to adjust this according to your own needs:
__Amount ("Extrusion Amount", Range(-0.0001, 0.0001)) = 0
  1. Couple the property with its respective variable:
float _Amount;
  1. Change the #pragma directive so that it now uses a vertex modifier. You can do this by adding vertex:function_name at the end of it. In our case, we have called the vert: function:
#pragma surface surf Standard vertex:vert
  1. Add the following vertex modifier:
void vert (inout appdata_full v) { v.vertex.xyz += v.normal * _Amount; ...

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.