Getting the blending right
Dizzy Egg

Hello, I'm trying to achieve the blending in the attached image (which I've crudely circled in red). Basically have a texture background, and then a white gradient (with alpha), and draw the white gradient over the texture, making it brighter in parts.

I've tried loads of combinations by can't get the setting right. From the image it seems like I need to set the blender to use the destination colour for the source, and the source alpha for the destination, but I'm a bit stumped!

Any pointers?

AceBlkwell

Sorry Dizzy, that's way above my level of expertise. Out of curiosity, what kind of results are you getting?

Edgar Reynaldo

Hello Dizzy! xD :D :)

Show code!

This will work to darken the scene.

al_set_blender(ALLEGRO_SRC_MINUS_DEST , ALLEGRO_DEST_COLOR , ALLEGRO_SRC_ALPHA);

This will work to brighten the scene (gamma);

al_set_blender(ALLEGRO_ADD , ALLEGRO_SRC_ALPHA , ALLEGRO_DEST_COLOR);

I think....
.
.
.

Allegro blend operations are a little strange, but it's shown best in the manual at liballeg. https://liballeg.org/a5docs/trunk/graphics.html#al_set_blender8-)

I think it's better to start at full gamma / color / opacity, and then blend shadowmaps on top. They're just inverse light maps colored gray and multiplied together.

But if you're looking to

8-)

Dizzy Egg

Ahh, it was:

al_set_blender(ALLEGRO_ADD, ALLEGRO_DEST_COLOR, ALLEGRO_ZERO);

That gives the desired result of multiplying the original color by the white gradient.

Doesn't look very pretty though, may look at shadowmaps!!

(I have a light shader but was trying to get some nice lighting going in the style of this https://www.youtube.com/watch?v=fsE1ddOas7A at about 4:52 in the video, the lovely lights!!)

Thread #618813. Printed from Allegro.cc