How to do it...

Perform the following steps to create a BlinnPhong lighting model:

  1. First, let's remove all of the current properties with their definitions in the SubShader block. Then we need to add our own properties to the Properties block so that we can control the look of the Specular highlight:
Properties 
{ 
  _MainTint ("Diffuse Tint", Color) = (1,1,1,1) 
  _MainTex ("Base (RGB)", 2D) = "white" {} 
  _SpecularColor ("Specular Color", Color) = (1,1,1,1) 
  _SpecPower ("Specular Power", Range(0.1,60)) = 3 
} 
  1. Then we need to make sure that we have created the corresponding variables in our CGPROGRAM block so that we can access the data from our Properties block, in our subshader:
sampler2D _MainTex; float4 _MainTint; float4 _SpecularColor; float ...

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.