Search Unity

How to recover the value of a pixel after multiplying by a factor

Discussion in 'General Graphics' started by JohnSonLi, Jan 12, 2015.

  1. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    If a pixel value say (r,g,b,a) , I multiply it by a factor - f, So i got a new value (r1,g1,b1,a1) = (r*f,g*f,b*f,a*f);
    If I later wanna recover it I have to divide the new by f.
    but if (r1,g1,b1,a1) or any one of the components is larger than 1,then it will be clamped to 1.
    thus I will never get the original value back buy simply division, I only got 1/f .......
    any better idea?
     
  2. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    just use a Vector 4 as a proxy to your color value
     
  3. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    thx,I will try