SpriteControl - Generated Sprites Alpha issue

Blitz3D Forums/Blitz3D Programming/SpriteControl - Generated Sprites Alpha issue

Kryzon(Posted 2006) [#1]
Hello all,

I'm currently using Sprite Control for Sprite managing and that sort of stuff. But I'm always getting the same problem: When I load a sprite with LoadImage3D() (The SpriteControl's command to load a sprite), I put the flag 2 (that means Alpha) in the function.
Well, the sprite doesn't get transparent, even if I draw a 10,10,10 RGB Picture to load it with Sprite Control. What happens is that i think sprites/textures generated from scratch in Blitz3D don't get alpha properties, don't know why. Every texture I create using CreateTexture() (with flag 2) and draw semi-transparent RGB to it, it just doesn't get alpha. What can i do to create textures/sprites from scratch and get them to be transparent (with and without SpriteControl)?
Hope you understand what i'm saying, my english sucks ;).

Thanks in advance,
Rafael.


jfk EO-11110(Posted 2006) [#2]
As soon as you use drawing commands to the texture buffer, the alpha channel will be "erased", say set to non-transparent. If I recall correctly the only command that is capable of setting alpha corretly is copyrect (besides Writepixel/fast).

Not sure what you meant by "and draw semi-transparent RGB to it" - how can you draw semi-transparent RGB? You'd rather draw normal RGB, plus an alpha value in the top byte of the 32bit ARGB value. DirectX 2D commands such as Line, Rect, Oval etc. do not support Alpha. So if you used some substitutes that are using writepixelfast, with alpha etc. then it SHOULD work. Tho you have to set the alpha bytes of every pixel, not only for the primitives you draw.


DH(Posted 2006) [#3]
Yeah, sux that writepixelfast is so slow.... There is a good world of fun that could be had if they weren't


Kryzon(Posted 2006) [#4]
Oh, ok. Maybe I didn't express myself the right way. Let me re-write:

What I wanted to do, is to load Sprites (using Sprite Control) that has Alpha in them (the flag 2).

Even though I create images like in photoshop that have different intensities in their pixels, like a dark grey, it just doesn't get transparent as it should.

Here's what i'm doing:
Sprite = LoadImage3D("alpha.bmp",2)

Although i put in the Alpha flag, the sprite isn't gettin transparent. It does work if i load it manually with LoadSprite(filename,2). (Loading manually works, but loading with the Sprite Control LoadImage3D doesn't, the sprite just keeps solid without alpha).


Dreamora(Posted 2006) [#5]
Alpha is only supported on PNG and TGA and you have to use the alpha mask or the layer alpha blend to actually get alpha in photoshop.


Kryzon(Posted 2006) [#6]
Yes, but i don't want to mask the sprites.
I want them to blend with the background, like if i load them with the Alpha Flag manually ( LoadSprite(sprite,2) ). What happens is that if i load the sprite with Sprite Control, even if i put in the flag 2, it just doesn't get the sprite to blend, i don't know why.
(image taken from Attack of the Groox - Encounter on Blubuzz)

Is there a way to get to something like this with Sprite Control?
I think i may be forgetting some important step to get sprites to react like that.


Ross C(Posted 2006) [#7]
Do you have a screenshot of what's happening?

You might want to look at these functions in the code archives. The first one i wrote and it will mask/alpha off the colour you pass across. So, if you draw your sprite and mask off the rest of the image with a colour such as RGB (255,0,255), then call my function, passing across the mask colour, it will add in the alpha information, making the mask colour invisible. It will leave the rest of the image untouched.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1013

This function by skidracer, basically smoothes the edges of the mask area, so the mask colour doesn't bleed through.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1131


Kryzon(Posted 2006) [#8]
Thanks for the posts so far guys, i think we are getting close to the problem.
Here is what's happening:


- Loading with LoadImage3D() (Sprite Control):



- Loading with LoadSprite() (Blitz3D Command)

This nice result here just happens when i use LoadSprite, but then I won't get Sprite Control's features. I guess i can't have everything i want :)

What happens is that i would like an alpha-blended sprite, but with SpriteControl's handling features, you know?

I believe that the only reason this happens is because when you manually create a texture in blitz, even if you put the flag 2, it doesn't get alpha blended (and Sprite Control is using a manually created texture to scale to a pixel-size or something like that).
Any way to solve this?

Thanks guys,
Rafael.


Ross C(Posted 2006) [#9]
Have you tried running the texture through that function i posted?


Kryzon(Posted 2006) [#10]
Yes, I implemented your Texture_Mask_Colour() function into the Sprite Control's functions. But it's still isn't working, the sprite keeps solid.

I'm starting to think that whatever texture or sprite you create manually in blitz3D, by using CreateTexture or CreateSprite, even if you put the alpha flag (2) when you create them, it just won't function properly.

I just don't get what's the difference from loading a sprite (and it gets just like i want) and creating one manually (doesn't get how i want, but will have sprite control's features). Hmm...I'm beggining to give up :(

If any one has a clue or sugestion to what i should do, please help. I was going to use alpha-blended sprites WITH Sprite control in order to get a decent HUD for my games, something like the screenshot of the game i posted the earlier. I wonder what that game used to get something like that...

Thanks again.


Ross C(Posted 2006) [#11]
Hmm, sprite control might use single surface stuff. If you could locate the mesh used, you could try using EntityFX command on the mesh, with the alphablend flag included.

If not, try using the EntityFX command on the actual sprite, with the alpha blend flag.

Does masking work btw?


Kryzon(Posted 2006) [#12]
Yes, masking is working. I believe alpha blending is the only mode that is not properly working. I will test the Sprite Control Basic version now, see if there is any difference.

Dang! got it to work! it seems that Alpha only works if I use an old version of SpriteControl, the Sprite Control BASIC.bb (wich is considered a 'bare bones' version), one that actually treats the sprites as 3d quads, wich is probably the reason it is working. Phew! finally!

As a gift for helping me, I shall reward everyone that posted here a free copy of the game I'm going to make using these sprites :) (I was going to publish it for free anyways :D )

Thank you for all for helping me!


Ross C(Posted 2006) [#13]
Heh, no worries. Seems like you helped yourself though. Glad you got it fixed :o)