InvertChannelData.shader 938 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Shader "Hidden/TriLib/InvertChannelData"
  2. {
  3. SubShader
  4. {
  5. // No culling or depth
  6. Cull Off ZWrite Off ZTest Always
  7. Pass
  8. {
  9. CGPROGRAM
  10. #pragma vertex vert
  11. #pragma fragment frag
  12. #include "UnityCG.cginc"
  13. struct appdata
  14. {
  15. float4 vertex : POSITION;
  16. float2 uv : TEXCOORD0;
  17. };
  18. struct v2f
  19. {
  20. float2 uv : TEXCOORD0;
  21. float4 vertex : SV_POSITION;
  22. };
  23. v2f vert(appdata v)
  24. {
  25. v2f o;
  26. o.vertex = UnityObjectToClipPos(v.vertex);
  27. o.uv = v.uv;
  28. return o;
  29. }
  30. sampler2D _MainTex;
  31. int _ChannelIndex;
  32. float4 frag(v2f i) : SV_Target
  33. {
  34. float4 col = tex2D(_MainTex, i.uv);
  35. switch (_ChannelIndex) {
  36. case 0:
  37. return 1.0-col.x;
  38. break;
  39. case 1:
  40. return 1.0 - col.y;
  41. break;
  42. case 2:
  43. return 1.0 - col.z;
  44. break;
  45. }
  46. return 1.0 - col.w;
  47. }
  48. ENDCG
  49. }
  50. }
  51. }