AVProVideo-Lit-Diffuse.shader 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. Shader "AVProVideo/Lit/Diffuse (texture+color+fog+stereo support)"
  2. {
  3. Properties
  4. {
  5. _Color("Main Color", Color) = (1,1,1,1)
  6. _MainTex("Base (RGB)", 2D) = "white" {}
  7. _ChromaTex("Chroma", 2D) = "white" {}
  8. [KeywordEnum(None, Top_Bottom, Left_Right, Custom_UV)] Stereo("Stereo Mode", Float) = 0
  9. [Toggle(STEREO_DEBUG)] _StereoDebug("Stereo Debug Tinting", Float) = 0
  10. [Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
  11. [Toggle(USE_YPCBCR)] _UseYpCbCr("Use YpCbCr", Float) = 0
  12. }
  13. SubShader
  14. {
  15. Tags { "Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="Geometry" }
  16. LOD 200
  17. CGPROGRAM
  18. #pragma surface surf Lambert vertex:VertexFunction
  19. // TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
  20. #pragma multi_compile MONOSCOPIC STEREO_TOP_BOTTOM STEREO_LEFT_RIGHT STEREO_CUSTOM_UV
  21. #pragma multi_compile __ APPLY_GAMMA
  22. #pragma multi_compile __ STEREO_DEBUG
  23. #pragma multi_compile __ USE_YPCBCR
  24. #include "AVProVideo.cginc"
  25. uniform sampler2D _MainTex;
  26. #if USE_YPCBCR
  27. uniform sampler2D _ChromaTex;
  28. uniform float4x4 _YpCbCrTransform;
  29. #endif
  30. uniform fixed4 _Color;
  31. struct Input
  32. {
  33. float2 uv_MainTex;
  34. float4 color;
  35. };
  36. void VertexFunction(inout appdata_full v, out Input o)
  37. {
  38. UNITY_INITIALIZE_OUTPUT(Input, o);
  39. #if STEREO_TOP_BOTTOM | STEREO_LEFT_RIGHT
  40. float4 scaleOffset = GetStereoScaleOffset(IsStereoEyeLeft(), true);
  41. o.uv_MainTex = v.texcoord.xy *= scaleOffset.xy;
  42. o.uv_MainTex = v.texcoord.xy += scaleOffset.zw;
  43. #elif STEREO_CUSTOM_UV
  44. o.uv_MainTex = v.texcoord.xy;
  45. if (!IsStereoEyeLeft())
  46. {
  47. o.uv_MainTex = v.texcoord1.xy;
  48. }
  49. #endif
  50. o.color = _Color;
  51. #if STEREO_DEBUG
  52. o.color *= GetStereoDebugTint(IsStereoEyeLeft());
  53. #endif
  54. }
  55. void surf(Input IN, inout SurfaceOutput o)
  56. {
  57. fixed4 c;
  58. #if USE_YPCBCR
  59. c = SampleYpCbCr(_MainTex, _ChromaTex, IN.uv_MainTex, _YpCbCrTransform);
  60. #else
  61. c = SampleRGBA(_MainTex, IN.uv_MainTex);
  62. #endif
  63. c *= IN.color;
  64. o.Albedo = c.rgb;
  65. o.Alpha = c.a;
  66. }
  67. ENDCG
  68. }
  69. Fallback "Legacy Shaders/Transparent/VertexLit"
  70. }