Alpha blending question...(DX8)

Started by
14 comments, last by Moe 22 years, 9 months ago
I am having a bit of trouble understanding alpha blending. I understand what it does, but I cant figure out how to do it. I have a texture that is faded from black to white, and I want to make the black transparent. I also don''t want to use additive alpha blending, just regular blending (so when I have several blended objects over eachother it doesn''t turn white). How would this be done?
Advertisement
Check out drunkenhyenas tutorials at
http://www.drunkenhyena.com/docs/d3d8/dhGrayScale.phtml

this one explaines how to turn a greyscale image to an alpha channel.

And use modulate instead of adding for alphas.

Possibility
I am afraid thats not quite what I am looking for. I just want to take a standard image (eg - bitmap, jpg, etc) and blend away the black without having to read through each pixel of the image (something like the pointsprite demo on the SDK). I know this is possible, I just don''t know the render states and texture stage states.
Moe, if you mean using alpha blending for transparent blits, download this:

http://home.att.net/~rpgbook/transblt.zip

Jim
Sorry, I think you will have to examine each pixel in the image no matter what...however, this (not to sure what your talking about...)maight beable to be done through hardware...not sure. but you will always need to find the value of the pixel before doing an operation on it or skipping over it otherwise tyou won''t get the results you''re lokking for.
I know it can be done with the right renderstates/texture stage states. I know this can be done because I have done it before with pointsprites. I tried to copy the exact renderstates/texture stage states but it didn't work (go ahead, call me dumb). When I figure it out I will be sure to post how to do it up here.

I would also like to figure out how to specify an amount to blend by instead of using the alpha part of the vertex color. That is quite possible, isn't it?

To err is human. To really foul things up requires a computer.

Edited by - Moe on June 29, 2001 12:16:40 AM
can''t ya just use color keying? you just want to make black (0,0,0) transparent, right?
No, I am not just trying to colorkey. I am trying to blend the darker colors so they are more transparent. Take a look at the Poinsprites sample in the SDK. The bitmap it loads in is faded from black to the orange color in the middle, and the black is blended out so there is no sharp edge between the orange and background.
I think you can achieve what you want by setting

SetTextureStageState 0, D3DTSS_SRCBLEND, D3DBLEND_SRCCOLOR
SetTextureStageState 0, D3DTSS_DESTBLEND, D3DBLEND_INVSRCCOLOR

Basically, that tells DX to take the color''s intensity as the alpha.
I think thats what I am after, but is it possible to do it without having an alpha value in the souce image, or do I need to load that texture in as a file type that has and alpha value?

This topic is closed to new replies.

Advertisement