1、Shader 中 Properties 属性:
Numbers and Sliders
name ("display name", 2D) = "defaulttexture" {}
name ("display name", Cube) = "defaulttexture" {}
name ("display name", 3D) = "defaulttexture" {}
Colors and Vectors
name ("display name", Color) = (number,number,number,number)
name ("display name", Vector) = (number,number,number,number)
Textures
name ("display name", 2D) = "defaulttexture" {}
name ("display name", Cube) = "defaulttexture" {}
name ("display name", 3D) = "defaulttexture" {}
2、Shader 中 #include 外部引用:
HLSLSupport.cginc ==>辅助宏和跨平台着色编译的定义。
UnityShaderVariables.cginc ==>常用的全局变量。
UnityCG.cginc ==>常用的辅助函数。
AutoLight.cginc ==>照明和阴影功能,例如,表面着色器在内部使用这个文件。
Lighting.cginc ==>标准的表面着色照明模型;当你在写表面着色器时自动包含。
TerrainEngine.cginc ==>地形和植被阴影的辅助功能。
3、Shader 中 #Pragma 编辑:
#pragma vertex name - 编译函数名作为顶点着色器。
#pragma fragment name - 编译函数名作为片段着色器。
#pragma geometry name - 编译函数名为DX10几何着色器。有了这个选项,就会自动打开“目标4.0”
#pragma hull name - 编译函数名为DX11外壳着色器。有了这个选项,就会自动打开目标5.0
#pragma domain name - 编译函数名为DX11域着色器。有了这个选项,就会自动打开目标5.0
//其他的编辑指令
#pragma target name - 哪个着色器目标要编译。有关详细信息,请参见着色器编译目标页面。
#pragma only_renderers space separated names - 只对给定的渲染器编译着色器。默认的着色器是为所有渲染器编译的。请参阅下面的渲染器以获得详细信息。
#pragma exclude_renderers space separated names - 不要为给定的渲染器编译着色器。默认的着色器是为所有渲染器编译的。请参阅下面的渲染器以获得详细信息。
#pragma multi_compile … - 用于处理多个着色器变体。
#pragma enable_d3d11_debug_symbols - 为DirectX 11编译的着色器生成调试信息,这将允许您通过Visual Studio 2012(或更高)的图形调试器调试着色器。
#pragma hardware_tier_variants renderer name - 为每个可运行选定的渲染器的硬件层生成多个着色器硬件变体。请参阅下面的渲染器以获得详细信息。
//2018.09.20
1、Material { Material Block } 材质
定义了 1 个顶点光照管道使用的材质
2、Lighting On \ Off 开启/关闭灯光
关闭或开启顶点光照
3、Cull Back / Front / Off 裁剪背面 / 前面 / 关闭
设置多边形的裁剪模式
4、 ZTest ( Less / Greater / LEqual / GEqual / Equal / NotEqual / Always )
设置深度测试模式(OpenGL 深度其实就是该象素点在3d世界中距离摄象机的距离,深度缓存中存储着每个象素点(绘制在屏幕上的)的深度值!深度测试决定了是否绘制较远的象素点(或较近的象素点),通常选用较近的,而较远优先能实现透视的效果!)
5、 ZWrite On / Off
设置深度写模式类型
6、 Fog { Fog Block }
设置雾化类型
7、 AlphaTest ( Less / Greater / LEqual / GEqual / Equal / NotEqual / Always ) CutoffValue
开启Alpha测试
8、 Blend SourceBlendMode DestBlendMode
设置Alpha混合模式
9、 Color color value
设置颜色,当顶点光效关闭时有效
10、 ColorMask RGB / A / 0 / any combination of R, G, B, A
设置颜色遮罩模式。将ColorMask设置为0表示关闭多有渲染的颜色管道。
11、 Offset OffsetFactor , OffsetUnits
设置深度偏移。提示:这个命令仅接受Unity3 3D的常数参数(不是Shader的参数)。
用于为图形设置深度的偏移
这个函数一般用于当两图形刚上处于同坐标或两个面在同一坐标重叠时。可以通过这个函数让其中一个图形或面的坐标自动偏移。
12、 SeparateSpecular On | Off
关闭或打开顶点照明单独的镜面反射光的颜色。
13、 ColorMaterial AmbientAndDiffuse | Emission 环境和漫反射|放射
计算顶点照明时使用的每个顶点颜色
14、 Texture Setup 纹理设置
当渲染状态设置以后,你可以用SetTexture命令指定这些纹理和他们的结合方式。
15、 SetTexture texture property { [Combine options] } 设置纹理
纹理设置固定功能的多纹理管线,如果使用定制的片断着色器将被忽略。
16、 Per-pixel Lighting 逐像素光照
逐像素光照管道的工作依赖于渲染对象在多个pass中。Unity3D一旦获得环境光和任何顶点的光照就开始渲染物体。然后,它在一个单独添加的pass中影响渲染的物体每1个光照的像素。
17、Per-vertex Lighting 逐顶点光照
逐顶点光照是Direct3d/OpenGl的标准光照模式,它的计算依赖于每一个顶点。打开光照后才能启动逐顶点光照。光照受Materialblock, ColorMaterial 和 SeparateSpecular命令影响。
//Shader中Blending 模式
Blend operations
The following blend operations can be used:
Add | Add source and destination together. |
Sub | Subtract destination from source. |
RevSub | Subtract source from destination. |
Min | Use the smaller of source and destination. |
Max | Use the larger of source and destination. |
LogicalClear | Logical operation: Clear (0) DX11.1 only. |
LogicalSet | Logical operation: Set (1) DX11.1 only. |
LogicalCopy | Logical operation: Copy (s) DX11.1 only. |
LogicalCopyInverted | Logical operation: Copy inverted (!s) DX11.1 only. |
LogicalNoop | Logical operation: Noop (d) DX11.1 only. |
LogicalInvert | Logical operation: Invert (!d) DX11.1 only. |
LogicalAnd | Logical operation: And (s & d) DX11.1 only. |
LogicalNand | Logical operation: Nand !(s & d) DX11.1 only. |
LogicalOr | Logical operation: Or (s | d) DX11.1 only. |
LogicalNor | Logical operation: Nor !(s | d) DX11.1 only. |
LogicalXor | Logical operation: Xor (s ^ d) DX11.1 only. |
LogicalEquiv | Logical operation: Equivalence !(s ^ d) DX11.1 only. |
LogicalAndReverse | Logical operation: Reverse And (s & !d) DX11.1 only. |
LogicalAndInverted | Logical operation: Inverted And (!s & d) DX11.1 only. |
LogicalOrReverse | Logical operation: Reverse Or (s | !d) DX11.1 only. |
LogicalOrInverted | Logical operation: Inverted Or (!s | d) DX11.1 only. |
Blend factors
All following properties are valid for both SrcFactor & DstFactor in the Blend command. Source refers to the calculated color, Destination is the color already on the screen. The blend factors are ignored if BlendOp is using logical operations.
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). |
Details
Below are the most common blend types
:
Blend SrcAlpha OneMinusSrcAlpha // Traditional transparency
Blend One OneMinusSrcAlpha // Premultiplied transparency
Blend One One // Additive
Blend OneMinusDstColor One // Soft Additive
Blend DstColor Zero // Multiplicative
Blend DstColor SrcColor // 2x Multiplicative