Unity3D的Shader基本结构—子着色器SubShader
2021-06-21 05:05
二、LOD级别
2.Material { Material Block }
最终颜色:
3.Lighting On | Off
4.Cull Back | Front | Off
5.ZTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always)
6.ZWrite On | Off
7.Fog { Fog Block }
8.AlphaTest (Less | Greater | LEqual | GEqual | Equal | NotEqual | Always) CutoffValue
9.Blend SourceBlendMode DestBlendMode
常用的混合模式:
10.Color Color value
11.ColorMask RGB | A | 0 | any combination of R, G, B, A
12.Offset OffsetFactor , OffsetUnits
13.SeparateSpecular On | Off
14.ColorMaterial AmbientAndDiffuse | Emission
假如设定LOD级别(默认时是200),我们可以在质量控制里面设置某个质量级别能支持的最大LOD级别。如果设定支持的lod级别比shader需要的级别低,那该shader就不可用。
参考网上的资料:
VertexLit及其系列 = 100
Decal, Reflective VertexLit = 150
Diffuse = 200
Diffuse Detail, Reflective Bumped Unlit, Reflective Bumped VertexLit = 250
Bumped, Specular = 300
Bumped Specular = 400
Parallax = 500
Parallax Specular = 600
这个模块控制了顶点光照的信息,包括漫反射、高光、环境光等
Diffuse: Color
默认颜色组件,基本颜色
Ambient: Color
环境颜色组件,物体在被RenderSettings里面设置的环境光照射时的颜色
Specular: Color
高光反射颜色
Shininess: Number
高光的锐利度,在0到1之间,0时高光巨大,1时高光尖锐。
Emission: Color
自发光,当物体没有被任何光线照射时的颜色。
Ambient * RenderSettings ambient setting +
(Light Color * Diffuse + Light Color * Specular) + Emission
控制顶点光照的开关
控制剔除的面
深度测试模式,小于、大于、小于等于、大于等于、等于、不等于、一直时,才显示。
深度写入的开关
这个模块可以给物体单独设置雾的效果。
示例:
Fog
{
Mode Exp2//Off | Global | Linear | Exp | Exp2
Color [_Color]
Density 0.1
Range 0,300
}
透明度测试,小于、大于、小于等于、大于等于、等于、不等于某值时显示
设置混合模式。
? One The value of one - use this to let either the source or the destination color come through fully.
? Zero
The value zero - use this to remove either the source or the destination values.
? SrcColor
The value of this stage is multiplied by the source color value.
? SrcAlpha The value of this stage is multiplied by the source alpha value.
? DstColor The value of this stage is multiplied by frame buffer source color value.
? DstAlpha The value of this stage is multiplied by frame buffer source alpha value.
? OneMinusSrcColor The value of this stage is multiplied by (1 - source color).
? OneMinusSrcAlpha The value of this stage is multiplied by (1 - source alpha).
? OneMinusDstColor The value of this stage is multiplied by (1 - destination color).
? OneMinusDstAlpha The value of this stage is multiplied by (1 - destination alpha).
Blend SrcAlpha OneMinusSrcAlpha //透明混合
Blend One One // 叠加
Blend OneMinusDstColor One // 软叠加
Blend DstColor Zero // 相乘
Blend DstColor SrcColor // 2x 相乘
当Light off时设置颜色
过滤颜色,如果参数是RGB的一种或几种时,将过滤参数的颜色,如果是0,将过滤所以颜色
设置Z缓存深度偏移
控制顶点光照的高光开关,如果开了,那么在物体最终颜色基础上再加上高光颜色
使用材质颜色代替环境光、漫反射或者自发光
文章标题:Unity3D的Shader基本结构—子着色器SubShader
文章链接:http://soscw.com/index.php/essay/96756.html