對Z深度的偏移
Offset 指令給了我們一個操作正常的ZTest 檢測結果的手段。
Offset有兩個參數,這兩個參數理解起來不是很直觀,而且具體實現是和硬件相關的
下面在實際例子中看他的效果
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 0, 0 // 通過綁定固定通道來使用定點色 BindChannels { Bind "Vertex", vertex // 綁定定點 Bind "Normal", normal Bind "Color", color Bind "Texcoord", texcoord0 Bind "Texcoord", texcoord1 } //給材質設置 貼圖 SetTexture [_MainTex] { Combine texture * primary double } } } FallBack "Diffuse" }
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
下面將 Offset 0, 0 改為 Offset -10000, 0
效果如下