AVProVideo-Internal-IMGUI-Transparent.shader 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. Shader "AVProVideo/Internal/IMGUI/Texture Transparent"
  2. {
  3. Properties
  4. {
  5. _MainTex("Texture", any) = "" {}
  6. _ChromaTex("Chroma", any) = "" {}
  7. _VertScale("Vertical Scale", Range(-1, 1)) = 1.0
  8. [KeywordEnum(None, Top_Bottom, Left_Right)] AlphaPack("Alpha Pack", Float) = 0
  9. [Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
  10. [Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
  11. }
  12. SubShader
  13. {
  14. Tags { "ForceSupported" = "True" "RenderType" = "Overlay" }
  15. Lighting Off
  16. Blend SrcAlpha OneMinusSrcAlpha
  17. Cull Off
  18. ZWrite Off
  19. ZTest Always
  20. Pass
  21. {
  22. CGPROGRAM
  23. #pragma vertex vert
  24. #pragma fragment frag
  25. // TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
  26. #pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
  27. #pragma multi_compile __ APPLY_GAMMA
  28. #pragma multi_compile __ USE_YPCBCR
  29. #include "UnityCG.cginc"
  30. #include "../AVProVideo.cginc"
  31. struct appdata_t
  32. {
  33. float4 vertex : POSITION;
  34. fixed4 color : COLOR;
  35. float2 texcoord : TEXCOORD0;
  36. };
  37. struct v2f
  38. {
  39. float4 vertex : SV_POSITION;
  40. fixed4 color : COLOR;
  41. float4 uv : TEXCOORD0;
  42. };
  43. uniform sampler2D _MainTex;
  44. #if USE_YPCBCR
  45. uniform sampler2D _ChromaTex;
  46. uniform float4x4 _YpCbCrTransform;
  47. #endif
  48. uniform float4 _MainTex_ST;
  49. uniform float4 _MainTex_TexelSize;
  50. uniform float _VertScale;
  51. v2f vert(appdata_t v)
  52. {
  53. v2f o;
  54. o.vertex = XFormObjectToClip(v.vertex);
  55. o.color = v.color;
  56. o.uv = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, TRANSFORM_TEX(v.texcoord, _MainTex), _VertScale < 0.0);
  57. return o;
  58. }
  59. fixed4 frag(v2f i) : SV_Target
  60. {
  61. fixed4 col;
  62. #if USE_YPCBCR
  63. col = SampleYpCbCr(_MainTex, _ChromaTex, i.uv.xy, _YpCbCrTransform);
  64. #else
  65. col = SampleRGBA(_MainTex, i.uv.xy);
  66. #endif
  67. #if ALPHAPACK_TOP_BOTTOM | ALPHAPACK_LEFT_RIGHT
  68. col.a = SamplePackedAlpha(_MainTex, i.uv.zw);
  69. #endif
  70. return col * i.color;
  71. }
  72. ENDCG
  73. }
  74. }
  75. Fallback off
  76. }