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

How it works...

The way shaders allow you to communicate the rendering properties of your material to their lighting model is via their SurfaceOutput. It is basically a wrapper around all the parameters that the current lighting model needs. It should not surprise you that different lighting models have different SurfaceOutput structs. The following table shows the three main output structs used in Unity and how they can be used:

The SurfaceOutput struct has the following properties:

  • fixed3 Albedo;: This is the diffuse color of the material
  • fixed3 Normal;: This is the tangent space, normal, if written
  • fixed3 Emission;: This is the color of the light emitted by the material (this property is declared as half3 in the Standard Shaders)
  • fixed Alpha;: This is the transparency of the material
  • half Specular;: This is the specular power from 0 to 1
  • fixed Gloss;: This is the specular intensity

The SurfaceOutputStandard struct has the following properties:

  • fixed3 Albedo;: This is the base color of the material (whether it's diffuse or specular)
  • fixed3 Normal;
  • half3 Emission;: This property is declared as half3, while it was defined as fixed3 in SurfaceOutput
  • fixed Alpha;
  • half Occlusion;: This is the occlusion (default 1)
  • half Smoothness;: This is the smoothness (0 = rough, 1 = smooth)
  • half Metallic;: 0 = non-metal, 1= metal

The SurfaceOutputStandardSpecular struct has the following properties:

  • fixed3 Albedo;
  • fixed3 Normal;
  • half3 Emission;
  • fixed Alpha;
  • half Occlusion;
  • half Smoothness;
  • fixed3 Specular;: This is the specular color. This is very different from the Specular property in SurfaceOutput as it allows you to specify a color rather than a single value.

Using a Surface Shader correctly is a matter of initializing the SurfaceOutput with the correct values.

For more information on creating Surface Shaders, check out the following link: https://docs.unity3d.com/Manual/SL-SurfaceShaders.html

主站蜘蛛池模板: 泾阳县| 博客| 巴彦淖尔市| 三河市| 闸北区| 丰城市| 淅川县| 秭归县| 象州县| 三穗县| 岚皋县| 鹤山市| 莱西市| 怀来县| 噶尔县| 九龙坡区| 清丰县| 寻乌县| 红桥区| 轮台县| 聂拉木县| 义马市| 大理市| 菏泽市| 绍兴县| 黑水县| 藁城市| 三明市| 石嘴山市| 大渡口区| 吕梁市| 平湖市| 临夏县| 穆棱市| 牡丹江市| 通江县| 册亨县| 泸水县| 天全县| 沙洋县| 金乡县|