Alpha map in 2D

Blitz3D Forums/Blitz3D Beginners Area/Alpha map in 2D

Moraldi(Posted 2006) [#1]
Hi again,
Is there any way to get alpha map results using the 'Image' functions provided from Blitz3D. To be more specific i want to create 2D buttons for user input. As far as i know you can set only one transparent color using MaskImage function but in my case this is not acceptable.

Thanks!


jhocking(Posted 2006) [#2]
The 2D commands built into Blitz3D do not support alpha transparency. You want a 2D-in-3D system, or a UI/sprites/HUD system.


Sir Gak(Posted 2006) [#3]
To achieve alpha in 2D, you'd have to manually compute the blending of background colors with your graphics that need to alpha overlay. The problem that can arise in this situation is that per-pixel shading in blitz3D is not good for real-time usage. The readpixelfast and writepixelfast commands (used with the lockbuffer/unlockbuffer commands) are just not fast enough. If you pre-computed the transparency blend for all situations, then you could *simulate* alpha-blending.

It's a shame Mark Sibley doesn't create an alpha-shaded 2D image function in blitz3D for those wanting to use B3D for 2d programming. Apparently, it's been added to BlitzMax (I don't have BMax, so I'm guessing).

You'd almost have to do a hack, as per jhocking, in which you use 2D-in-3D, ie. use your images basically as all sprites.


Ross C(Posted 2006) [#4]
You can fake 50% transparency, by applying a checkered mask to your image. Checker the image in your choosen image mask colour, and when draw at a decent res, 800x600 or above, it looks decent and is super fast.


Moraldi(Posted 2006) [#5]
well guys, thanks for your guidelines. I understand that there are many ways but they demand programming effort and time. In my case (i need quickly results) it would be preferable to get a "ready to use" solution. Meanwhile i searched in google for "sprites in blitz3d" and i saw a very impressive demo of the Sprite Candy library. It cost about 30€ and i believe its worth the money. But i don't know if there is still support and how easy it is.


Ross C(Posted 2006) [#6]
Try looking for N-sprite 2.


mindstorms(Posted 2006) [#7]
Look in the code archives under graphics for tbm images...it worked for me!


Moraldi(Posted 2006) [#8]
Thanks
i will look...


jfk EO-11110(Posted 2006) [#9]
http://www.blitzbasic.com/codearcs/codearcs.php?code=773
http://www.blitzbasic.com/codearcs/codearcs.php?code=1173