NormalBlendYUV.shader 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. Shader "NRSDK/NormalBlendYUV"
  2. {
  3. Properties
  4. {
  5. _MainTex("_MainTex", 2D) = "white" {}
  6. _UTex("U", 2D) = "white" {}
  7. _VTex("V", 2D) = "white" {}
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType" = "Opaque" }
  12. LOD 100
  13. ZTest Always
  14. ZWrite Off
  15. Pass
  16. {
  17. CGPROGRAM
  18. #pragma vertex vert
  19. #pragma fragment frag
  20. #include "UnityCG.cginc"
  21. struct appdata
  22. {
  23. float4 vertex : POSITION;
  24. float2 uv : TEXCOORD0;
  25. };
  26. struct v2f
  27. {
  28. float2 uv : TEXCOORD0;
  29. UNITY_FOG_COORDS(1)
  30. float4 vertex : SV_POSITION;
  31. };
  32. sampler2D _MainTex;
  33. sampler2D _UTex;
  34. sampler2D _VTex;
  35. float4 _MainTex_ST;
  36. v2f vert(appdata v)
  37. {
  38. v2f o;
  39. o.vertex = UnityObjectToClipPos(v.vertex);
  40. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  41. return o;
  42. }
  43. fixed4 frag(v2f i) : SV_Target
  44. {
  45. fixed2 uv = fixed2(i.uv.x, 1 - i.uv.y);
  46. fixed4 ycol = tex2D(_MainTex, uv);
  47. fixed4 ucol = tex2D(_UTex, uv);
  48. fixed4 vcol = tex2D(_VTex, uv);
  49. float r = ycol.a + 1.4022 * vcol.a - 0.7011;
  50. float g = ycol.a - 0.3456 * ucol.a - 0.7145 * vcol.a + 0.53005;
  51. float b = ycol.a + 1.771 * ucol.a - 0.8855;
  52. fixed4 col_bg = fixed4(b, g, r, 1);
  53. col_bg.rgb = GammaToLinearSpace(col_bg.rgb);
  54. return col_bg;
  55. }
  56. ENDCG
  57. }
  58. }
  59. }