cull
back/front/off
zwrite
on/off
ztest
less/greater/equal/gequal/notequal/always
blend
blendop 混合方式 可选参数:
add(默认混合操作)/sub/resub/min/max
(min/max的混合因子只会是one,也就是说,无论blend后面写的是因子是什么,都是以one来计算)
blend 混合因子 可选参数:
one/zero/srcColor/srcAlpha/oneMinusSrcColor/oneMinusdstAlpha...
blendop为add/sub/revsub时,混合方式为:
O = SrcFactor * S + DstFactor * D,中间的加号根据blendop的不同而不同
blendop为min/max时,混合方式为:
O = min或max(S,D),也就是说这里的混合方式并没有用到混合因子,但是blend依旧需要写
因为 blend srcFacotr dstFactor这一句,不仅给出了混合因子,也意味着开启了混合
blendop和blend都可以写:
blend xxx xxx,xxx xxx,这样的写法是针对rgb和alpha运用不同的混合方式或者混合因子,不像如此写的话,rgb和alpha的所使用的混合方式和混合因子即为同一个。
在不开启blend的时候,RGB Alpha是直接覆盖buffer的
buffer中的alpha与rgb的计算过程一样,不用觉得alpha特别
Offset
推测这个offset的偏移值是针对zTest阶段,在进行深度测试的时候,将当前pass的深度用offset进行调整再与深度缓冲区中的值进行比对。
offset是结局stiching和z-fighting的最佳途径之一。
offset语法: offset factor,units
factor和units都是用来影响z-test的参数,影响方式为:
offset = (m * factor) + (r * units)
m为三角面的斜率,即三角面片与近剪裁面越接近平行,则m值越接近于0。
r是能产生在窗口坐标系的深度值中可分辨的差异的最小值,r是由具体实现OpenGL的平台指定的一个常量。
offset为正的时候物体更远离摄像机,为负的时候物体跟接近摄像机。
PassName
语法 Name "MYPASSNAME"
这用于其他shader可以直接使用该pass,名字必须使用大写
UsePass "myshader/MYPASSNAME"
LOD(Subshader RenderSetup)
相关的c# Shader属性:
material.shader.maximumLOD | 实例属性,针对个体。material修改会使得其实例化。sharedMaterial修改才是修改的项目资源。 |
Shader.globalMaximumLOD | 静态属性,针对全局 |
-
实例的LOD默认数值为-1,即表示实例没有生效LOD
-
实例的LOD优先级高于全局的LOD(在都设置了的情况下)
-
全局的LOD默认数值为2147483647(2^31 - 1也就是int.MaxValue,有符号整型数能表示的最大值),即表示任何数量的LOD都可以渲染
-
要使得LOD不生效,就把实例/全局LOD设置回他们的默认值
-
所设置的LOD大于等于SubShader中的LOD值,则视为此SubShader通过,否则查找下一个SubShader是否通过