AVProVideo-VR-InsideSphere-StereoUV.shader 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. Shader "AVProVideo/VR/InsideSphere Unlit (stereo+fog) Stereo UV"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "black" {}
  6. [Toggle(STEREO_DEBUG)] _StereoDebug ("Stereo Debug Tinting", Float) = 0
  7. [Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType"="Opaque" "IgnoreProjector" = "True" "Queue" = "Background" }
  12. ZWrite On
  13. //ZTest Always
  14. Cull Front
  15. Lighting Off
  16. Pass
  17. {
  18. CGPROGRAM
  19. #include "UnityCG.cginc"
  20. #include "AVProVideo.cginc"
  21. //#pragma target 3.0
  22. #pragma vertex vert
  23. #pragma fragment frag
  24. //#define STEREO_DEBUG 1
  25. //#define HIGH_QUALITY 1
  26. #pragma multi_compile_fog
  27. // TODO: replace use multi_compile_local instead (Unity 2019.1 feature)
  28. #pragma multi_compile __ STEREO_DEBUG
  29. #pragma multi_compile __ APPLY_GAMMA
  30. struct appdata
  31. {
  32. float4 vertex : POSITION; // vertex position
  33. float2 uv : TEXCOORD0; // texture coordinate 1
  34. float2 uv2 : TEXCOORD1; // texture coordinate 2
  35. };
  36. struct v2f
  37. {
  38. float4 vertex : SV_POSITION; // clip space position
  39. float2 uv : TEXCOORD0; // texture coordinate
  40. UNITY_FOG_COORDS(1)
  41. #if STEREO_DEBUG
  42. float4 tint : COLOR;
  43. #endif
  44. };
  45. uniform sampler2D _MainTex;
  46. uniform float4 _MainTex_ST;
  47. v2f vert(appdata v)
  48. {
  49. v2f o;
  50. o.vertex = XFormObjectToClip(v.vertex);
  51. if (IsStereoEyeLeft())
  52. {
  53. o.uv.xy = TRANSFORM_TEX(v.uv, _MainTex);
  54. o.uv.xy = float2(1.0 - o.uv.x, o.uv.y);
  55. }
  56. else
  57. {
  58. o.uv.xy = TRANSFORM_TEX(v.uv2, _MainTex);
  59. o.uv.xy = float2(1.0 - o.uv.x, o.uv.y);
  60. }
  61. #if STEREO_DEBUG
  62. o.tint = GetStereoDebugTint(IsStereoEyeLeft());
  63. #endif
  64. UNITY_TRANSFER_FOG(o, o.vertex);
  65. return o;
  66. }
  67. fixed4 frag (v2f i) : SV_Target
  68. {
  69. float2 uv;
  70. uv = i.uv;
  71. fixed4 col = tex2D(_MainTex, uv);
  72. #if APPLY_GAMMA
  73. col.rgb = GammaToLinear(col.rgb);
  74. #endif
  75. #if STEREO_DEBUG
  76. col *= i.tint;
  77. #endif
  78. UNITY_APPLY_FOG(i.fogCoord, col);
  79. return fixed4(col.rgb, 1.0);
  80. }
  81. ENDCG
  82. }
  83. }
  84. }