AVProVideo-Lit-Transparent-Diffuse.shader 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Shader "AVProVideo/Lit/Transparent Diffuse (texture+color+fog+packed alpha)"
  2. {
  3. Properties
  4. {
  5. _Color("Main Color", Color) = (1,1,1,1)
  6. _MainTex("Base (RGB)", 2D) = "black" {}
  7. _ChromaTex("Chroma", 2D) = "black" {}
  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 { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  15. LOD 200
  16. ZWrite Off
  17. Blend SrcAlpha OneMinusSrcAlpha
  18. Cull Off
  19. CGPROGRAM
  20. #pragma surface surf Lambert vertex:VertexFunction alpha
  21. // TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
  22. #pragma multi_compile ALPHAPACK_NONE ALPHAPACK_TOP_BOTTOM ALPHAPACK_LEFT_RIGHT
  23. #pragma multi_compile __ APPLY_GAMMA
  24. #pragma multi_compile __ USE_YPCBCR
  25. #include "AVProVideo.cginc"
  26. uniform sampler2D _MainTex;
  27. uniform float4 _MainTex_ST;
  28. uniform float4 _MainTex_TexelSize;
  29. #if USE_YPCBCR
  30. uniform sampler2D _ChromaTex;
  31. uniform float4x4 _YpCbCrTransform;
  32. #endif
  33. uniform fixed4 _Color;
  34. struct Input
  35. {
  36. float4 texcoords;
  37. };
  38. void VertexFunction(inout appdata_full v, out Input o)
  39. {
  40. UNITY_INITIALIZE_OUTPUT(Input, o);
  41. o.texcoords = OffsetAlphaPackingUV(_MainTex_TexelSize.xy, v.texcoord, _MainTex_ST.y < 0.0);
  42. }
  43. void surf(Input IN, inout SurfaceOutput o)
  44. {
  45. fixed4 col;
  46. #if USE_YPCBCR
  47. col = SampleYpCbCr(_MainTex, _ChromaTex, IN.texcoords.xy, _YpCbCrTransform);
  48. #else
  49. col = SampleRGBA(_MainTex, IN.texcoords.xy);
  50. #endif
  51. #if ALPHAPACK_TOP_BOTTOM | ALPHAPACK_LEFT_RIGHT
  52. col.a = SamplePackedAlpha(_MainTex, IN.texcoords.zw);
  53. #endif
  54. col *= _Color;
  55. o.Albedo = col.rgb;
  56. o.Alpha = col.a;
  57. }
  58. ENDCG
  59. }
  60. Fallback "Legacy Shaders/Transparent/VertexLit"
  61. }