方便簡單的敵人身影遮掩身形提示….好罷其實我不明白自己剛剛說了啥.
大概就是這一種 shader
情況:

Ref: http://www.danielkiedrowski.com/2012/07/wall-vision-outline-image-effect-unity-asset-store/

Ref: https://www.assetstore.unity3d.com/en/#!/content/24707

Properties{
// step 1, the color you wanted.
_OcclusionColor("OcclusionColor", Color) = (0.2426471,0.07530426,0,1)
}
SubShader{
Tags{
// step 2, Geometry make the vision display ontop of the others. e.g. building, walls.
"Queue" = "Geometry+1" "RenderType" = "Opaque"
}
LOD 100
Pass{
ZWrite Off
ZTest Greater
Blend One Zero
// step 3, Geometry make the vision display ontop of the others. e.g. building, walls.
Color[_OcclusionColor]
}
// step 4, write a normal drawing shader here.
// because it's ZWrite On and it's called after pervious, therefore it can override the 1st Pass result
// if camera can really saw it on screen.
Pass{
Name "FORWARD"
Tags{
"LightMode" = "ForwardBase"
}
......
}
.....
}
簡單的四個步驟
- 顏色
- Geometry 地形+1.. 總之比其他建築物或牆等等使用的 shader 級別高, +1,+2,+3 如此類推.
- 第一個 Pass, Zwrite off, Color[xxx] 就是為了直接把顏色輸出到 surf.
- 正常顯示的 shader
因為 #4 的 Pass 在一般能看見的情況下, 是後繪的關係, 所以第一層的 Pass 就被取代, 所以畫面結果沒有顯示出來.
但是當人物被普通的建築或牆遮蓋的時候, 因為 ZDepth 的關係, 第二層的 Pass 不會繪畫. 而第一層的純顏色 Pass 就顯示出來.