Search Unity

Getting pixel color behind transparent layer and then performing color replacement

Discussion in 'Shaders' started by killakiwi, Aug 26, 2014.

  1. killakiwi

    killakiwi

    Joined:
    Sep 5, 2013
    Posts:
    22
    Hello :)

    So I'm trying to make this:
    upload_2014-8-26_20-22-2.png
    look like this:
    upload_2014-8-26_20-22-53.png
    As you can see, the inside of the orange boxes applies a sort of filter which could either increase the contrast or replace the grey with white. I'm not sure which is the better route.

    I've found shaders which can replace colours, but not the colour of the texture in the background. I don't even know how to get that value. I've seen _GrabTexture but that doesn't seem to apply to vertices?

    Is what I'm trying to achieve possible with shaders?

    Thanks for reading
     
  2. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    Look at blend modes.
    http://docs.unity3d.com/Manual/SL-Blend.html

    To do rudimentary contrast and luminance control of the back buffer:

    Blend One SrcAlpha

    In your pixel shader output alpha as your multiplier and RGB as your offset

    note: The ROP (the blend mode) are not programmable yet, so you are limited.
    If you need more control, you need to grab the back buffer (in texture) , and this will allow you to read the back buffer in the shader.