PDA

View Full Version : How does blending and gamma work?



monkeyscience
09-16-2011, 02:09 PM
I've noticed alpha blending tends to wash out my textures and wrote a little test:
http://www.reinot.com/hologl/blendTest.html

The left image is an alpha-blended PNG using (SRC_ALPHA,ONE_MINUS_SRC_ALPHA). The other premultiplies the texture's rgb with alpha in the shader and then blends with (ONE,ONE_MINUS_SRC_ALPHA). How come they look different?

I would expect the outcome to be the right image, the left one looks washed out. I can't think of a reason for the discrepancy other than some gamma correction happens on the fragment before the blending function gets to it. Context premultipliedAlpha is set to false, are there other context flags for gamma correction?

monkeyscience
10-14-2011, 10:25 AM
Nevermind! This is alpha-blended alpha cutting holes into my canvas and premultiplied alpha fixing the problem. Apologies for the n00b-post :oops: .