InvertChannelData.shader 1000 B

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