Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to make only specific colors show?

Discussion in 'Shaders' started by FeelinBlu, Apr 8, 2016.

  1. FeelinBlu

    FeelinBlu

    Joined:
    May 8, 2015
    Posts:
    5
    We have a Black and White game and we want certian colors to show up in certian conditions.
    For example everything would be black and white except red for a certain point. Then everything would be black and white except for blue!
    Any suggestions?
     
  2. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    Make an Image Effect shader applied to your camera.

    dot your color with a float3 to convert to greyscale there are different numbers out there... something like (0.2,0.7,0.7).

    lerp between each of the above values and 1 based on your _ShowRed property(probably a 0,1 Range).
     
  3. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,864
  4. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    If you want to get this done a little bit cheaper then a post process, (they are not so nice on mobiles sadly), you can create custom shaders for everything where you control this. I would not suggest it for anything but mobiles however.
    To do this "easily" you'd use a global shader variable, controlling what colors are allowed to show.
     
  5. FeelinBlu

    FeelinBlu

    Joined:
    May 8, 2015
    Posts:
    5
    We're trying to see if we can code it, but if it's gets to that we will definitely consider it. Thank you!
     
  6. FeelinBlu

    FeelinBlu

    Joined:
    May 8, 2015
    Posts:
    5
    So would this change the amount of each color bleeding through the greyscale on the shader?
     
  7. FeelinBlu

    FeelinBlu

    Joined:
    May 8, 2015
    Posts:
    5
    We initially thought of doing this, but we thought it'd be VERY time consuming. Also, won't it just end up being untextured rather than greyscale?
     
  8. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Actually it wouldn't take as long as you might think, as you'd use most of what already exists.
    Why would it be untextured? All I'd suggest doing is run the RGB trough a luminance function, (NOT the average of them, that is not how people percieve stuff!), and then lerp between the two "versions".
    I can help out here if you want me to, in that case send me a pm.
     
  9. FeelinBlu

    FeelinBlu

    Joined:
    May 8, 2015
    Posts:
    5
    Our coder is going to give it a try today! I'll be sure to update, your suggestion did spring an "Oh!" from him!