4
$\begingroup$

I'm trying to figure out a problem for a program I'm writing. I am calculating color values, and they get premultiplied by the alpha. I want to figure out what the alpha was before hand and divide the color by that.

I have the new premultiplied alpha (let's say alpha is $.25$ or $25\%$)

$\alpha = .25 * .25$;

$\alpha = .0625$

Given this information, I want to figure out $.25$ from $.0625$

$.0625 = x \times x$

My math is super bad/rusty. Any help would be great!

$\endgroup$
  • 5
    $\begingroup$ Do you know what a square root is?... $\endgroup$ – Cure Jun 22 '14 at 2:48
  • $\begingroup$ Ah, easy. Thanks. $\endgroup$ – M2tM Jun 22 '14 at 2:49
3
$\begingroup$

As per Cure's suggestion:

sqrt(.0625) does what I want!

*EDIT: For those curious, you can see the related issue I had: https://stackoverflow.com/questions/24346585/opengl-render-to-texture-with-partial-transparancy-translucency-and-then-rende

This solved my problem 100%.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.