| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //如果用在会被mask切掉的UI上,把Stencil Comparison改成4,Stencil ID改成2
- Shader "MoleGame/Particles/Additive" {
- Properties{
- _TintColor("Tint Color", Color) = (0.5,0.5,0.5,0.5)
- _MainTex("Particle Texture", 2D) = "white" {}
- //4 equal
- _StencilComp("Stencil Comparison", Float) = 8
- //2 ui mask
- _Stencil("Stencil ID", Float) = 0
- _StencilOp("Stencil Operation", Float) = 0
- _StencilWriteMask("Stencil Write Mask", Float) = 255
- _StencilReadMask("Stencil Read Mask", Float) = 255
- _ColorMask("Color Mask", Float) = 15
- }
- Category{
- Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" }
- Stencil{
- Ref[_Stencil]
- Comp[_StencilComp]
- Pass[_StencilOp]
- ReadMask[_StencilReadMask]
- WriteMask[_StencilWriteMask]
- }
- ZTest[unity_GUIZTestMode]
- ColorMask[_ColorMask]
- Blend SrcAlpha One
- Cull Off Lighting Off ZWrite Off
- SubShader{
- Pass{
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma target 2.0
- //#pragma multi_compile_particles
- //#pragma multi_compile_fog
- #include "UnityCG.cginc"
- sampler2D _MainTex;
- float4 _MainTex_ST;
- fixed4 _TintColor;
- struct appdata_t {
- float4 vertex : POSITION;
- fixed4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- struct v2f {
- float4 vertex : SV_POSITION;
- fixed4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- v2f vert(appdata_t v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.color = v.color;
- o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
- return o;
- }
- fixed4 frag(v2f i) : SV_Target
- {
- fixed4 col = i.color * _TintColor * tex2D(_MainTex, i.texcoord);
- #ifdef UNITY_UI_CLIP_RECT
- col.a *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect);
- #endif
- return col;
- }
- ENDCG
- }
- }
- }
- }
|