Search Unity

Color swap shader

Discussion in 'Shaders' started by danhunter, Mar 24, 2017.

  1. danhunter

    danhunter

    Joined:
    Jul 2, 2015
    Posts:
    3
    Hey,

    I've found a lot of threads around applying color to a greyscale image, or swapping colors of a pixel art palette, but neither of these achieve quite what I'm attempting.. and I'm really just trying to establish if it is possible, or if I should try a different solution.

    I'm trying to achieve an effect like this



    .. where a range of colors is replaced with another when under a mask. I was thinking I could supply a shader with two ramps, and it finds the coords of one color, and looks up the replacement color.

    Is this possible? Or would I be better off rendering two identical scenes and using a render texture for the masked area.

    Thank you so much.
     
  2. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    Yes, one shader can do all you need. Just lerp between the two ramps based on your mask.