How to do it...

Open up the SimpleDiffuse shader you've created and make the following changes:

  1. In the Properties section, remove all of the variables except for _Color:
  Properties   {    _Color ("Color", Color) = (1,1,1,1)  }
  1. From the SubShader{} section, remove the _MainTex, _Glossiness, and _Metallic variables. You should not remove the reference to uv_MainTex as Cg does not allow the Input struct to be empty. The value will simply be ignored.
  2. Also, remove the UNITY_INSTANCING_BUFFER_START/END macros and the comments used with them.
  1. Remove the content of the surf() function and replace it with the following:
void surf (Input IN, inout SurfaceOutputStandard o) {  o.Albedo = _Color.rgb; }
  1. Your shader should look as follows:
Shader "CookbookShaders/Chapter03/SimpleDiffuse" ...

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.