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

Introduction

Surface Shaders have been introduced in Chapter 1, Creating Your First Shader, as the main type of shader used in Unity. This chapter will show 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 surface function and stored in a structure called surface output. Secondly, the surface output is passed to a lighting model. This is a special function that will also take information about the nearby lights in the scene. Both 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 3, Understanding Lighting Models, while Chapter 5, Vertex Functions, will focus on vertex modifiers:

主站蜘蛛池模板: 泊头市| 海门市| 卓资县| 东安县| 郧西县| 临沭县| 抚顺县| 巍山| 绥德县| 海原县| 张北县| 天柱县| 林口县| 尼勒克县| 富阳市| 五大连池市| 马鞍山市| 贵溪市| 南投市| 旌德县| 女性| 邵阳县| 新和县| 余庆县| 元朗区| 凤山市| 宁武县| 宜兰市| 墨玉县| 武汉市| 兴国县| 高邑县| 林甸县| 环江| 林周县| 文安县| 黑山县| 奎屯市| 桑植县| 黑山县| 大同县|