官术网_书友最值得收藏!

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:

主站蜘蛛池模板: 江津市| 夹江县| 沈丘县| 兴国县| 高邑县| 北碚区| 五台县| 广饶县| 平泉县| 咸宁市| 民乐县| 夏津县| 汾西县| 桦甸市| 潼南县| 金阳县| 新丰县| 新兴县| 华坪县| 盐源县| 雷州市| 西华县| 睢宁县| 资阳市| 大渡口区| 盐源县| 会同县| 且末县| 若尔盖县| 台湾省| 冀州市| 吴忠市| 云阳县| 张家港市| 容城县| 游戏| 彭阳县| 宣恩县| 页游| 彰武县| 靖州|