- Unity 2018 Shaders and Effects Cookbook
- John P. Doran Alan Zucconi
- 199字
- 2021-06-18 19:04:16
Introduction
Surface Shaders were introduced in Chapter 2, Creating Your First Shader, as the main type of shader that's used in Unity. This chapter will show you in detail what these actually are and how they work. Generally speaking, there are two essential steps in every Surface Shader. First, you have to specify certain physical properties of the material that you want to describe, such as its diffuse color, smoothness, and transparency. These properties are initialized in a function called the surface function and are stored in a structure called the SurfaceOutput. Secondly, the SurfaceOutput is passed to a lighting model. This is a special function that will also take information about the nearby lights in the scene. Both of these parameters are then used to calculate the final color for each pixel of your model. The lighting function is where the real calculations of a shader take place as it's the piece of code that determines how light should behave when it touches a material.
The following diagram loosely summarizes how a Surface Shader works. Custom lighting models will be explored in Chapter 4, Understanding Lighting Models, while Chapter 6, Vertex Functions, will focus on vertex modifiers:

- C# 7 and .NET Core Cookbook
- The Modern C++ Challenge
- 新一代通用視頻編碼H.266/VVC:原理、標準與實現
- Raspberry Pi Networking Cookbook(Second Edition)
- 精通API架構:設計、運維與演進
- Hands-On JavaScript High Performance
- Python Geospatial Development(Second Edition)
- 算法訓練營:提高篇(全彩版)
- Mastering Android Development with Kotlin
- Webpack實戰:入門、進階與調優(第2版)
- Machine Learning for Developers
- Koa與Node.js開發實戰
- Isomorphic JavaScript Web Development
- Java EE應用開發及實訓
- Switching to Angular 2