Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Weird blitting behavior [A5] (Video included)

This thread is locked; no one can reply to it. rss feed Print
Weird blitting behavior [A5] (Video included)
Hyena_
Member #8,852
July 2007
avatar

I use png images so I naturally have alpha channel in my graphics layers for parallax scrolling. Whenever I change the depth of my unit that can be either behind or in front of bushes layer the edges of the bush change their color value a bit. It isn't ugly or anything but I can notice a change just because the queue of layers changes.

video

Trent Gamblin
Member #261
April 2000
avatar

Not using premultiplied alpha can cause edges to be darker than they should be. Don't know if that's the problem in this case though. Are you using linear filtering and/or non-premultiplied alpha?

A little addition: This could happen if you're drawing different layers with different blend modes, usually when using ALPHA, INVERSE_ALPHA instead of ONE, INVERSE_ALPHA.

Hyena_
Member #8,852
July 2007
avatar

Heh :D I guess I found the bug..

That circle is drawn using
al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);

but scaled sprite images use this:
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
The bug was with drawing scaled image that didn't set blender at all, so at some points it used the first one and at some points the second one.

That blender function is quite confusing. I had to use the first one mentioned for circle drawing to have custom transparency but images that already have alpha channel had to use some other blender set.

Trent Gamblin
Member #261
April 2000
avatar

Not a bad guess, eh 8-).

Go to: