面的剔除 Cull
在渲染的时候,默认情况下是只有朝向摄像机的面才会被渲染,可以告诉Unity,我想渲染哪一个朝向的面,使用Cull命令在计算体积阴影的时候会用到对Cull的操作来计算和物体相交的投影
Cull 有三种
Cull Off 不剔除
Cull Back 剔除背面(背向摄像机的面)
Cull Front 剔除前面 (朝向摄像机的面)
Shader "Custom/PassFive" {
Properties {
//定义一个贴图
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader
{
Tags {"RenderType" = "Opaque" "IGNOREPROJECTOR" = "TRUE" "QUEUE" = "Transparent"}
LOD 200
Pass
{
//AlphaTest Greater 0.6
//AlphaTest Less 0.5
//AlphaTest Greater 0.4
//AlphaTest Less 0.9
Blend SrcAlpha One
//Blend SrcColor OneMinusSrcColor
//BlendOp RevSub
//ColorMask RG
//ColorMask RB
//ZTest Greater
//Offset -10000, 0
Cull Back
// 通过绑定固定通道来使用定点色
BindChannels
{
Bind "Vertex", vertex // 绑定定点
Bind "Normal", normal
Bind "Color", color
Bind "Texcoord", texcoord0
Bind "Texcoord", texcoord1
}
//给材质设置 贴图
SetTexture [_MainTex]
{
Combine texture * primary double
}
}
}
FallBack "Diffuse"
}
使用剔除背面 Cull Back 视觉上不会有影响,因为剔除的面是本来就看不见的
下面使用 Cull Front