ALPHA

Started by
2 comments, last by NotTaxes 22 years ago
Howdy, Can someone tell me how to change the alpha value of a single pixel in DX8 texture? Ideally I would like to merge an alpha texture with a normal texture, but if it has to be done on a per-pixel basis that''s also fine. I already know how to use the texturestages to blend textures together and how to use the material settings to change the alpha of an entire texture. What I''m trying to do is optionally change the transparency of individual pixels in a texture before I render it (for example, a glowing portal where the center of it pulses with more or less transparency). I can use multiple textures and just animate, but it''s really tedious to create all those textures just to create an effect this simple! Thanks
'Doing the impossible is kind of fun' - Walt Disney
Advertisement
This thread is getting close to the answer to your question...

http://www.gamedev.net/community/forums/topic.asp?topic_id=90479

www.lp.org
www.lp.org
quite simple, just do a LockRect() on the texture, change the alpha values (it should be a 32bit texture), then Unlock() the texture. as long as you dont try reading from the texture, this should be pretty fast (as long as you dont do this for too many textures and try to only update when needed), memory efficent, and more compatible across video cards compared to using things like pixel shaders. if you feel that you need the previous alpha values to calculate the new values, then keep a local copy of the texture in a buffer(ie not a d3d8 texture, but a simple malloc''d or new''d buffer). this ensures that you dont get penalized for reading from vram (which is pretty heavy). also make sure you do all modifications during one lock per frame, too many locks will slow things down. especially when there is no need for it. you should know how to read and write 32bit argb values from a dx surface, otherwise you better do some research on that as well (its quite simple).
Thanks a million for the responses. That''s great info.

Cheers
'Doing the impossible is kind of fun' - Walt Disney

This topic is closed to new replies.

Advertisement