Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "_Test/Transparent With Depth Mask"
- {
- Properties
- {
- _MainTex ("Main Texture", 2D) = "white" {}
- _DepthMask ("Depth Mask", 2D) = "white" {}
- }
- SubShader
- {
- Tags { "Queue" = "Transparent-1" }
- ZWrite Off
- Pass
- {
- Blend SrcAlpha OneMinusSrcAlpha // alpha blending
- CGPROGRAM
- #pragma exclude_renderers flash gles ps3 xbox360
- #pragma fragmentoption ARB_precision_hint_fastest
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- // uniforms
- uniform sampler2D _MainTex;
- uniform float4 _MainTex_ST;
- // structs
- struct vertexInput
- {
- float4 vertex : POSITION; // position in object coordinates
- float4 texcoord : TEXCOORD0; // 0th set of texture coordinates (UV)
- };
- struct fragmentInput
- {
- float4 pos : SV_POSITION;
- half2 uv : TEXCOORD0;
- };
- // functions
- fragmentInput vert(vertexInput i)
- {
- fragmentInput o;
- o.pos = mul(UNITY_MATRIX_MVP, i.vertex);
- o.uv = TRANSFORM_TEX(i.texcoord, _MainTex);
- return o;
- }
- half4 frag(fragmentInput i) : COLOR
- {
- return tex2D(_MainTex, i.uv);
- }
- ENDCG
- } // end pass
- Pass
- {
- //Blend SrcAlpha OneMinusSrcAlpha // alpha blending
- Blend Zero One
- ZWrite On
- CGPROGRAM
- #pragma exclude_renderers flash gles ps3 xbox360
- #pragma fragmentoption ARB_precision_hint_fastest
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- // uniforms
- uniform sampler2D _DepthMask;
- uniform float4 _DepthMask_ST;
- // structs
- struct vertexInput
- {
- float4 vertex : POSITION; // position in object coordinates
- float4 texcoord : TEXCOORD0; // 0th set of texture coordinates (UV)
- };
- struct fragmentInput
- {
- float4 pos : SV_POSITION;
- half2 uv : TEXCOORD1;
- };
- struct fragmentOutput
- {
- half4 color : COLOR;
- float depth : DEPTH;
- };
- // functions
- fragmentInput vert(vertexInput i)
- {
- fragmentInput o;
- o.pos = mul(UNITY_MATRIX_MVP, i.vertex);
- o.uv = TRANSFORM_TEX(i.texcoord, _DepthMask);
- return o;
- }
- fragmentOutput frag(fragmentInput i) : COLOR
- {
- fragmentOutput o;
- //o.color = half4(0.5, 0.5, 0.5, 0.0);
- o.color = half4(0.0);
- if (i.uv.x > 0.0)
- o.depth = 0.0;
- else
- o.depth = 1.0;
- return o;
- }
- ENDCG
- } // end pass
- } // end SubShader
- FallBack "Diffuse"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement