123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
- Shader "Custom/UIScreenBlend"
- {
- Properties
- {
- [PerRendererData]
- _MainTex("Sprite Texture", 2D) = "white" {}
- _Color("Tint", Color) = (1,1,1,1)
- _StencilComp("Stencil Comparison", Float) = 8
- _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
- }
- SubShader
- {
- Tags
- {
- "Queue" = "Transparent"
- "IgnoreProjector" = "True"
- "RenderType" = "Transparent"
- "PreviewType" = "Plane"
- }
- Stencil
- {
- Ref[_Stencil]
- Comp[_StencilComp]
- Pass[_StencilOp]
- ReadMask[_StencilReadMask]
- WriteMask[_StencilWriteMask]
- }
- Cull Off
- Lighting Off
- ZWrite Off
- ZTest[unity_GUIZTestMode]
- Fog { Mode Off }
- Blend SrcAlpha OneMinusSrcAlpha
- ColorMask[_ColorMask]
- GrabPass { }
- Pass
- {
- CGPROGRAM
- #include "UnityCG.cginc"
- #pragma vertex ComputeVertex
- #pragma fragment ComputeFragment
- sampler2D _MainTex;
- sampler2D _GrabTexture;
- fixed4 _Color;
- struct VertexInput
- {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- struct VertexOutput
- {
- float4 vertex : SV_POSITION;
- fixed4 color : COLOR;
- half2 texcoord : TEXCOORD0;
- float4 screenPos : TEXCOORD1;
- };
- VertexOutput ComputeVertex(VertexInput vertexInput)
- {
- VertexOutput vertexOutput;
- vertexOutput.vertex = UnityObjectToClipPos(vertexInput.vertex);
- vertexOutput.screenPos = vertexOutput.vertex;
- vertexOutput.texcoord = vertexInput.texcoord;
- vertexOutput.color = vertexInput.color * _Color;
- return vertexOutput;
- }
- fixed4 Screen(fixed4 a, fixed4 b)
- {
- fixed4 r = 1.0 - (1.0 - a) * (1.0 - b);
- r.a = b.a;
- return r;
- }
- fixed4 ComputeFragment(VertexOutput vertexOutput) : SV_Target
- {
- half4 color = tex2D(_MainTex, vertexOutput.texcoord) * vertexOutput.color;
- float2 grabTexcoord = vertexOutput.screenPos.xy / vertexOutput.screenPos.w;
- grabTexcoord.x = (grabTexcoord.x + 1.0) * .5;
- grabTexcoord.y = (grabTexcoord.y + 1.0) * .5;
- #if UNITY_UV_STARTS_AT_TOP
- grabTexcoord.y = 1.0 - grabTexcoord.y;
- #endif
- fixed4 grabColor = tex2D(_GrabTexture, grabTexcoord);
- return Screen(grabColor, color);
- }
- ENDCG
- }
- }
- Fallback "UI/Default"
- }
|