Advertisement
Guest User

InvertColors.shader

a guest
Apr 19th, 2019
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Hidden/InvertColors"
  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.  
  12.         Pass
  13.         {
  14.         Stencil{
  15.             Ref 1
  16.             ReadMask 1
  17.             Comp NotEqual
  18.             Pass Keep
  19.         }
  20.             CGPROGRAM
  21.             #pragma vertex vert
  22.             #pragma fragment frag
  23.  
  24.             #include "UnityCG.cginc"
  25.  
  26.             struct appdata
  27.             {
  28.                 float4 vertex : POSITION;
  29.                 float2 uv : TEXCOORD0;
  30.             };
  31.  
  32.             struct v2f
  33.             {
  34.                 float2 uv : TEXCOORD0;
  35.                 float4 vertex : SV_POSITION;
  36.             };
  37.  
  38.             v2f vert(appdata v)
  39.             {
  40.                 v2f o;
  41.                 o.vertex = UnityObjectToClipPos(v.vertex);
  42.                 o.uv = v.uv;
  43.                 return o;
  44.             }
  45.  
  46.             sampler2D _MainTex;
  47.  
  48.             fixed4 frag(v2f i) : SV_Target
  49.             {
  50.                 fixed4 col = tex2D(_MainTex, i.uv);
  51.             // inverted colors
  52.             col.rgb = 1 - col.rgb;
  53.             return col;
  54.         }
  55.         ENDCG
  56.     }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement