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

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:

主站蜘蛛池模板: 绥滨县| 广宁县| 伊川县| 平定县| 崇左市| 方正县| 昆明市| 托克逊县| 洱源县| 三门县| 军事| 永川市| 涡阳县| 迁西县| 滨州市| 红原县| 阜南县| 措美县| 乌审旗| 长宁区| 巧家县| 湟源县| 平阴县| 怀集县| 湘乡市| 渝中区| 浪卡子县| 辛集市| 甘洛县| 梅州市| 广丰县| 南召县| 南雄市| 驻马店市| 二连浩特市| 茌平县| 大丰市| 宝山区| 双柏县| 六安市| 锦屏县|