How it works...

The way shaders allow you to communicate the rendering properties of your material to their lighting model is via their SurfaceOutput. It is basically a wrapper around all the parameters that the current lighting model needs. It should not surprise you that different lighting models have different SurfaceOutput structs. The following table shows the three main output structs used in Unity and how they can be used:

Type of shaders

Standard

Physically-Based Lighting Models

Diffuse

Any Surface Shader

SurfaceOutput

Standard

SurfaceOutputStandard

Specular

Any Surface Shader

SurfaceOutput

Standard (Specular setup)

SurfaceOutputStandardSpecular

The SurfaceOutput struct has the following 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.