The material and lighting parameters are used to control the built-in vertex lighting. Vertex lighting is the standard Direct3D/OpenGL lighting model that is computed for each vertex. Lighting on turns it on. Lighting is affected by Material block, ColorMaterial and SeparateSpecular commands.
Per-pixel lights are usually implemented with custom vertex/fragment programs and don't use vertex lighting. For these you don't use any of the commands described here, instead you define your own vertex and fragment programs where you do all lighting, texturing and anything else yourself.
Vertex Coloring & Lighting is the first effect to gets calculated for any rendered geometry. It operates on the vertex level, and calculates the base color that is used before textures are applied.
The top level commands control whether to use fixed function lighting or not, and some configuration options. The main setup is in the Material Block, detailed further below.
Color Color 颜色
Sets the object to a solid color. A color is either four RGBA values in parenthesis, or a color property name in square brackets.
设置对象纯色。可以是一种RGBA颜色值(在括号中的),或颜色属性的名称(在方括号中的)。
Material { Material Block } 材质
The Material block is used to define the material properties of the object.
材质块是用来定义对象的材质性能
Lighting On | Off 灯光开关
For the settings defined in the Material block to have any effect, you must enable Lighting with the Lighting On command. If lighting is off instead, the color is taken straight from the Color command.
为了使在材质块中定义的设置有效,您必须启用 Lighting On命令开启光照。如果灯光关闭,则直接通过Color命令获得颜色。
SeparateSpecular On | Off
This command makes specular lighting be added to the end of the shader pass, so specular lighting is unaffected by texturing. Only has effect whenLighting On is used.
这个命令将镜面光照添加到Shader 通道的末尾,这样能使镜面反射光不被纹理影响。这个效果仅仅当照明开启时有效。
ColorMaterial AmbientAndDiffuse | Emission 颜色材质 环境漫反射光照 及放射光
makes per-vertex color be used instead of the colors set in the material. AmbientAndDiffuse replaces Ambient and Diffuse values of the material;Emission replaces Emission value of the material.
使用每一个顶点颜色去替换在材质中设置的颜色。AmbientAndDiffuse 替换环境漫反射光照的值。Emission 替换掉放射光的值。
Emission 可以理解为物体自发光。
Material Block 材质块
This contains settings for how the material reacts to the light. Any of these properties can be left out, in which case they default to black (i.e. have no effect).
Diffuse Color 漫反射颜色
The diffuse color component. This is an object's base color.
这个是物体最基础的颜色。
Ambient Color 环境色
The ambient color component. This is the color the object has when it's hit by the ambient light set in the RenderSettings.
当物体被环境光影响时候给物体设置颜色,这个取决于在RenderSettings中设置的环境颜色。
Specular Color 反射光
The color of the object's specular highlight.
设置物体的高光反射颜色
Shininess Number 清晰度
The sharpness of the highlight, between 0 and 1. At 0 you get a huge highlight that looks a lot like diffuse lighting, at 1 you get a tiny speck.
突出清晰度,值在0和1之间。为0时候,你得到1个巨大的高光看起来像很多漫射光照;为1时候,你得到一个小的斑点。
Emission Color 自发光颜色
The color of the object when it is not hit by any light.
当没被其他光线影响时候,物体本身的自发光颜色。
The full color of lights hitting the object is:
当物体被所有光线照射时候他的颜色的计算公式如下:
Ambient * RenderSettings ambient setting +
(Light Color * Diffuse + Light Color * Specular) + Emission
The light parts of the equation (within parenthesis) is repeated for all lights that hit the object.
在括号中的那部分光线计算,是计算所有照射到物体上的光线。
Typically you want to keep the Diffuse and Ambient colors the same (all builtin Unity shaders do this).