YUV.shader 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //======= Copyright (c) Stereolabs Corporation, All rights reserved. ===============
  2. //Transforms the RGBA texture into an YUV
  3. Shader "Custom/Green Screen/ YUV"
  4. {
  5. Properties
  6. {
  7. _MainTex ("Texture", 2D) = "white" {}
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType"="Opaque" }
  12. Pass
  13. {
  14. CGPROGRAM
  15. #pragma vertex vert
  16. #pragma fragment frag
  17. #include "UnityCG.cginc"
  18. #include "../../../SDK/Helpers/Shaders/ZED_Utils.cginc"
  19. struct appdata
  20. {
  21. float4 vertex : POSITION;
  22. float2 uv : TEXCOORD0;
  23. };
  24. struct v2f
  25. {
  26. float2 uv : TEXCOORD0;
  27. float4 vertex : SV_POSITION;
  28. };
  29. sampler2D _MainTex;
  30. float4 _MainTex_ST;
  31. int _isLinear;
  32. v2f vert (appdata v)
  33. {
  34. v2f o;
  35. o.vertex = UnityObjectToClipPos(v.vertex);
  36. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  37. return o;
  38. }
  39. float4 frag (v2f i) : SV_Target
  40. {
  41. #ifndef UNITY_COLORSPACE_GAMMA
  42. return float4(RGBtoYUV(LinearToGammaSpace(tex2D(_MainTex, i.uv).bgr)), 1);
  43. #else
  44. return float4(RGBtoYUV(tex2D(_MainTex, i.uv).bgr), 1);
  45. #endif
  46. }
  47. ENDCG
  48. }
  49. }
  50. }