Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by OhiraKyou · Jul 29, 2012 at 07:03 AM · colorcrosshairfilterinvert

Invert filter reticule

I have a working reticle, but I'd like to use it as an invert filter so that bits of the scene behind it are rendered with their colors inverted. This results in the reticle's visibility being consistent yet non-obstructive. Below is a demonstrative screenshot from Minecraft. Some players may not notice this, but I sure as hell do. And, I like it.

My current reticle is a GUITexture, but I can change it if doing so were to make this effect possible.

Minecraft crosshair

invert.jpg (94.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ScroodgeM · Jul 29, 2012 at 07:43 AM

use this shader and plane with alpha-texture in front of camera.

InvertColor.shader

Shader "Unity Answers/InvertColor" { Properties { _MainTex ("Alpha (A) only", 2D) = "white" {} _AlphaCutOff ("Alpha cut off", Range(0,1)) = 1 } SubShader { Tags { "Queue" = "Transparent+10" } Pass { Fog { Mode Off } Blend OneMinusDstColor Zero ZWrite Off

         CGPROGRAM

         #pragma vertex vert
         #pragma fragment frag
 
         sampler2D _MainTex;
         float _AlphaCutOff;

         struct appdata
         {
             float4 vertex : POSITION;
             float4 texcoord : TEXCOORD0;
         };

         struct v2f
         {
             float4 pos : SV_POSITION;
             float4 uv : TEXCOORD0;
         };

         v2f vert (appdata v)
         {
             v2f o;
             o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
             o.uv = float4(v.texcoord.xy, 0, 0);
             return o;
         }

         half4 frag( v2f i ) : COLOR
         {
             half4 c = 1;
             c.a = tex2D(_MainTex, i.uv.xy).a;
             clip(_AlphaCutOff - c.a);
             return c;
         }
         ENDCG
     }
 }

}

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image OhiraKyou · Jul 29, 2012 at 09:10 AM 0
Share

Excellent! I used a quad to cut down on triangles, and it looks great. I see significant potential elsewhere for this as well. $$anonymous$$any thanks, good sir.

avatar image Sonoshee · Sep 08, 2015 at 04:57 PM 0
Share

I still don't know how to use this shader. Any step-by-step please?

avatar image Animo1985 · Jan 27 at 01:04 AM 0
Share

Thanks a lot! That saved me a lot of time!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Invert The Color Of A GUIText Crosshair? 1 Answer

Is it possible to invert all colors of sprites based on the camera? 1 Answer

Font Color changing shader [color changes based on what background color is] 1 Answer

How do I invert the color of ui text to make it more readable, on a messy background? 4 Answers

Making FPS Reticule Change 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges