1. 程式人生 > >unity使三維物體不被其他物體遮擋

unity使三維物體不被其他物體遮擋

核心:更改zwrite
shader程式碼如下:

Shader "Custom/ZOffShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Transparent"  "Queue" = "Geometry+1"}
LOD 200
Pass{
Color (1,0,0,1)
ZTest Always
ZWrite Off
SetTexture[_MainTex] {
//constantColor (0,0,1,1)
//combine constant * texture 
}
}
Pass{
Material{
Diffuse (1,1,1,1)
                Ambient (1,1,1,1)
            }
            
Lighting On
Color(1,0,0,1)
SetTexture [_MainTex]{Combine texture * primary DOUBLE}
}
} 
FallBack "Diffuse"
}

如圖
在這裡插入圖片描述