Ala the ground in this picture:{"name":"WormsArmageddon1.PNG","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/d\/cd522b2ea198b49ac72533a93431b1c6.png","w":633,"h":252,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/d\/cd522b2ea198b49ac72533a93431b1c6"}

-----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs

It's possible to do masked blends using the features of Allegro 5 only by using al_set_blender. I do this to generate automatic blends for my game's tile maps. Here's a snippet from my code that should be helpful:

You can also look at the ex_depth_mask example, it does something similar without a shader, using the depth buffer as a mask. Stencil support definitely would be nice as well, especially in cases where you need both depth and stencil buffers at the same time.

Thanks! It took me awhile to things to sink in (they still aren't great), but the biggest error between the sample code and mine was that I forgot to convert my "map" bitmap's black color to an alpha channel. Once I called that function, it works great!

However, there is one downside to the depth test method (other than losing normal use of the depth buffer while using it for masking). What about smooth transitions?

If you wanted something to be drawn using variable alpha levels, how would you frame it? Is it exactly like that "rounded rectangle" thread that's also going on?

Keep in mind, these alphas/blenders are still very confusing to me so please break it down and elaborate.

Thank you.

-----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs

I haven't used it in a while (blending methods changed slightly in subsequent versions of allegro) but I just tested it and it seemed to work. This image shows a mask image (top_image), a texture image (bottom_image), and the example program putting the two together on a blue background.

If you go to the header file here, you'll see there are variants of the function, too. You can apply use your own blending modes, and/or transforms to the top/bottom images, and/or supply your own surface bitmap so that it's not created each time. There isn't a variant for looping the texture on the bottom to fit the mask, but you could use draw_textured_rectangle or draw_offset_textured_rectangle for that here).

All of this is still in the works, I don't have docs for this stuff, yet.

It's very confusing. Back when I was working on this function, I had a program that generated all possible blends (hundreds of images, if I recall) just so I could find the correct blending sequence & bitmap order I was looking for. Which bitmap do you draw on the surface? Which one do you draw on top of that? Does it read the surface or the drawn bitmap? ALLEGRO_BLEND_MODE_WHUT?

Background is drawn normally, the "map" (black for nothing, any other color for land) is converted to alpha, and then a texture is printed through that. The texture is tiled 2x2 right now to show its possible. Nothing too fancy, but it's baby steps.

-----sig:“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs