Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "SGG/Special/DepthPaste"
- {
- Properties{
- _MainCamDepthTex("Texture", 2D) = "white" {}
- [HideInInspector] _MainTex("Texture", 2D) = "white" {}
- }
- SubShader{
- // markers that specify that we don't need culling
- // or comparing/writing to the depth buffer
- Cull Off
- ZWrite Off
- ZTest Always
- Pass{
- CGPROGRAM
- //include useful shader functions
- #include "UnityCG.cginc"
- //define vertex and fragment shader
- #pragma vertex vert
- #pragma fragment frag
- sampler2D _MainTex;
- sampler2D _MainCamDepthTex;
- sampler2D _CameraDepthTexture;
- struct appdata {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
- struct v2f {
- float4 position : SV_POSITION;
- float2 uv : TEXCOORD0;
- };
- v2f vert(appdata v) {
- v2f o;
- o.position = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
- fixed4 frag(v2f i) : SV_TARGET{
- fixed4 col = tex2D(_MainTex, i.uv);
- float depth0 = tex2D(_MainCamDepthTex, i.uv).r;
- float depth = tex2D(_CameraDepthTexture, i.uv).r;
- if (depth < depth0)
- col.a = 0;
- return col;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement