How to do it...

With our scene ready to go, let's double-click on our newly created shader to open it in the code editor:

  1. Let's begin with our shader and populate the Properties block:
Properties {  _MainTex ("Base (RGB)", 2D) = "white" {}  _tintAmount ("Tint Amount", Range(0,1)) = 0.5  _ColorA ("Color A", Color) = (1,1,1,1)  _ColorB ("Color B", Color) = (1,1,1,1)  _Speed ("Wave Speed", Range(0.1, 80)) = 5  _Frequency ("Wave Frequency", Range(0, 5)) = 2  _Amplitude ("Wave Amplitude", Range(-1, 1)) = 1}
  1. We now need to tell Unity that we are going to be using a vertex function by adding the following to the #pragma statement:
CGPROGRAM#pragma surface surf Lambert vertex:vert
  1. In order to access the values that have been given to us by our properties, ...

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.