Fixed pipeline shader (Pass channel must be written in SubShader)
Shader instruction sequence diagram
Rander Setup
Properties
Properties |
Float | _FloatValue("a floating point number", float) = 0.4 |
Range float (Range) | _RangeValue("A range float",Range(1,100)) = 50 | |
Four-dimensional (Vector) | _VectorValue("A four-dimensional number",Vector) = (1,1,1,1) | |
Color | _ColorValue("a color value",Color) = (1,0,0,1) | |
Level 2 Textures (2D) | _Texture2D("A 2nd order texture",2D) = ""{} | |
Non-level 2 texture (Rect) | _TextureRect("A non-level 2 texture",Rect) = ""{} | |
Cubemap (Cube) | _TextureCube("A cube map",Cube) = ""{} |
Color
Fixed rendering a color() : Color(0,0,0.6,1) |
Fixed rendering a variable color[] : Color[_MainColor] |
Material
premise | Vertex lighting needs to be turned on → Lighting On/Off | |
Material |
Diffuse color (Diffuse) | |
Ambient Reflection Color (Ambient) | ||
Prerequisite: Specular reflection needs to be turned on ( SeparateSpecular On | Off) Shininess |
||
Specular color | ||
Emission color (Emission) |
Set up polygon culling
Cull Back/Front/Off
Depth test (judging the depth of the model, rendering the model when satisfied)
Prerequisite: Need to write to the depth buffer
ZWrite On | Off | On (if it is turned on, if the judgment is satisfied, only the model frame will be rendered and the color will not be rendered) |
Off (if it is turned off, the model can be rendered and the color can be rendered if the judgment is satisfied) |
Ztest
Ztest | Less (less than), LEqual (less than or equal to) |
Greater (greater than), GLqual (greater than or equal to) | |
Equal (equal), NotEqual (not equal) | |
Always (Renders all pixels. This is functionally equivalent to AlphaTest Off .) |
|
Never (don't render any pixels) |
Pass
{
// 进行深度测试,当前像素的深度大于缓存里的深度
// 说明当前像素在缓存像素的后面
// 通俗来讲就是被挡住了
ZTest Greater
// 关闭深度缓存
ZWrite Off
// 被挡住渲染该颜色
Color(1,0,0,1)
}
Pass
{
// 进行深度测试,当前像素的深度小于或等于缓存里的深度
// 说明当前像素不在缓存像素的后面
// 通俗来讲就是没有被挡住了
ZTest LEqual
// 没被挡住渲染该颜色
Color(0,0,1,1)
}
What is depth?
Distance of vertices & pixels from the camera | The closer the distance, the smaller the depth |
The farther the distance the greater the depth |
Blend
Blend |
Alpha (Blending): Blend SrcAlpha OneMinusSrcAlpha |
Adding up: Blend One One | |
Softer addition: Blend One OneMinusDstColor | |
Multiplication: Blend DstColor Zero | |
2x Multiplication: Blend DstColor SrcColor | |
开启透明混合:Blend SrcAlpha OneMinusSrcAlpha |
Tags
SubShader标签Queue |
测试需要关闭ZTest | ||||||||
|
|||||||||
Tags{"Queue" = "Transparent+1"} |
TextureSetup
SetTexture[TexturePropertyName]{TextureBlock}
前提 | Lighting On | |
stc【颜色源】 |
Primary是来自光照计算的颜色或是它绑定时的顶点颜色 | |
Texture是在SetTexture中被定义的纹理的颜色 | ||
Previous是上一次Set Texture的结果 | ||
Constant是被ConstantColor定义的颜色 | 固定颜色:constantColor(1,1,1,1) |
combine |
暗:combine src1 * src2 亮:combine src1 + src2 combine src1 - src2 |
combine src1 lerp(src2) src3 | |
双倍/四倍————Double \ Quad | |
RGB与A分离 |