Search Unity

Green Screen Effect

Discussion in 'Shaders' started by brandon, Jun 5, 2008.

  1. brandon

    brandon

    Joined:
    Mar 29, 2008
    Posts:
    15
    I'm having problems implementing this shader.

    I basically need to make a green screen.

    There will be two textures.
    One has many colors in it, but large areas of green.
    The second is the source texture.
    The shader needs to look at the first texture and replace any part that is green with the corresponding pixels from the second texture.

    I will need to change the color on it as well so I can set it up as a blue screen if needed.

    Anyone know how i can do that?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    with a simple fragment program which generates the outcomming texture basing on 2 incomming textures.
    The first is the one that can have green, the second one would be the alternative

    then you would read the green pixel color component and if it meets your requirement, use the alternative textures pixel instead of the primary ones.
     
  3. brandon

    brandon

    Joined:
    Mar 29, 2008
    Posts:
    15
    After reading through the shader documentation, I think I need to use ColorMask for this? Thats all I can figure out though. Anyone have a little more detail on what to use here? I can't figure out how to use the mask to pick which pixels will be replaced in the final texture.
     
  4. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370