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

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:

主站蜘蛛池模板: 偃师市| 丰顺县| 兴安盟| 尼玛县| 溆浦县| 新竹市| 寿宁县| 会理县| 白沙| 天台县| 松滋市| 个旧市| 金坛市| 昭觉县| 大兴区| 松溪县| 乐安县| 澎湖县| 博白县| 习水县| 宜兴市| 金华市| 民县| 比如县| 海盐县| 沙洋县| 普兰店市| 东阿县| 宜丰县| 蒲城县| 东乌珠穆沁旗| 墨江| 桦南县| 工布江达县| 云安县| 卓资县| 贵南县| 南川市| 平江县| 济源市| 镇平县|