AVProMovieCapture_SideBySideAlpha.shader 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. Shader "Hidden/AVProMovieCapture/SideBySideAlpha"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. }
  7. SubShader
  8. {
  9. Tags { "RenderType"="Opaque" }
  10. Lighting Off
  11. LOD 100
  12. Pass
  13. {
  14. CGPROGRAM
  15. #pragma vertex vert
  16. #pragma fragment frag
  17. #pragma multi_compile ALPHA_TOP_BOTTOM ALPHA_LEFT_RIGHT
  18. #pragma multi_compile __ FLIPPED SCREEN_FLIPPED
  19. #include "UnityCG.cginc"
  20. struct appdata
  21. {
  22. float4 vertex : POSITION;
  23. float2 uv : TEXCOORD0;
  24. };
  25. struct v2f
  26. {
  27. float2 uv : TEXCOORD0;
  28. float4 vertex : SV_POSITION;
  29. };
  30. sampler2D _MainTex;
  31. float4 _MainTex_ST;
  32. v2f vert (appdata v)
  33. {
  34. v2f o;
  35. o.vertex = UnityObjectToClipPos(v.vertex);
  36. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  37. #if ALPHA_TOP_BOTTOM
  38. #if FLIPPED || (SCREEN_FLIPPED && !(SHADER_API_MOBILE && SHADER_API_VULKAN))
  39. o.uv.y = 1.0 - ((o.vertex.y + 1.0) / 2.0);
  40. #else
  41. o.uv.y = (o.vertex.y + 1.0) / 2.0;
  42. #endif
  43. #else
  44. o.uv.x = (o.vertex.x + 1.0) / 2.0;
  45. #if FLIPPED || (SCREEN_FLIPPED && !(SHADER_API_MOBILE && SHADER_API_VULKAN))
  46. // Intentionally blank
  47. #else
  48. o.uv.y = (o.vertex.y + 1.0) / 2.0;
  49. #endif
  50. #endif
  51. return o;
  52. }
  53. fixed4 frag (v2f i) : SV_Target
  54. {
  55. float4 col;
  56. #if ALPHA_TOP_BOTTOM
  57. #if SCREEN_FLIPPED
  58. if( i.uv.y > 0.5 )
  59. {
  60. float texAlpha = tex2D(_MainTex, float2(i.uv.x, (i.uv.y * 2.0) - 1.0)).a;
  61. col = float4(texAlpha, texAlpha, texAlpha, 1.0);
  62. }
  63. else
  64. {
  65. col = tex2D(_MainTex, float2(i.uv.x, (i.uv.y * 2.0)));
  66. }
  67. #else
  68. if( i.uv.y < 0.5 )
  69. {
  70. float texAlpha = tex2D(_MainTex, float2(i.uv.x, (i.uv.y * 2.0))).a;
  71. col = float4(texAlpha, texAlpha, texAlpha, 1.0);
  72. }
  73. else
  74. {
  75. col = tex2D(_MainTex, float2(i.uv.x, ((i.uv.y * 2.0) - 1.0)));
  76. }
  77. #endif
  78. #else
  79. if( i.uv.x > 0.5 )
  80. {
  81. float texAlpha = tex2D(_MainTex, float2( ((i.uv.x * 2.0) - 1.0), i.uv.y)).a;
  82. col = float4(texAlpha, texAlpha, texAlpha, 1.0);
  83. }
  84. else
  85. {
  86. col = tex2D(_MainTex, float2((i.uv.x * 2.0), i.uv.y));
  87. }
  88. #endif
  89. return col;
  90. }
  91. ENDCG
  92. }
  93. }
  94. }