1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- Shader "Custom/InvertShader"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma multi_compile_instancing
- #include "UnityCG.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- UNITY_VERTEX_OUTPUT_STEREO
- };
- v2f vert(appdata v)
- {
- v2f o;
- UNITY_SETUP_INSTANCE_ID(v);
- UNITY_INITIALIZE_OUTPUT(v2f, o); //Insert
- UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //Insert
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv = v.uv;
- return o;
- }
- //sampler2D _MainTex;
- UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex); //Insert
- fixed4 frag(v2f i) : SV_Target
- {
- UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); //Insert
- fixed4 col = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.uv); //Insert
- // just invert the colors
- col.rgb = 1 - col.rgb;
- return col;
- }
- ENDCG
- }
- }
- }
|