Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Rej

Alpha blending (per pixel) using D3D... (Last Repost)

This topic is 6658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been trying to solve the following problem for the last few days... I have an image with a mask as a seperate file (bitmap that represents its alpha channel). My first solution to blitting this image with its alpha channel was to create a D3D function to do this... First I''d create an ARGB surface (32-bit), insert the image into it, then put the mask bitmap into the alpha channel of the ARGB surface. Then I''d blit (DrawPrimitive) it into the buffer, then flip. The problem with this solution is that it doesn''t work on all cards or even the same card with different drivers. For example with a TNT card and Detonator 2.0 drivers, the resulting FPS with the above solution is around 170 FPS. With the same card but with the new Detonator 3.0, the FPS goes down to 5.0 FPS (!!! I''ve contacted NVidia about it.. no answers so far). Also, the above solution won''t work properly with a banshee Voodoo card if desktop is set to 16-bit depth (result is garbage) but will work ok at 32-bit depth desktop (but at around 3.0 FPS on celeron 400). Of course, its probably something I coded that screws things up .. I''m in no way an expert with D3D altho I have a good understanding of DirectDraw (and starting to understand TEXTUREd surfaces as well) Anyhow, I then thought that I could probably (maybe, not sure) use Single Pass multitexturing to obtain the same result without having to convert surfaces (to ARGB 32-bit) or having to fill the alpha channel with the mask bitmap, and probably fix the previous problem with the different cards/drivers. So I sit down and start checking the various examples around (SDK) but I must admit that I don''t understand most of the flags required for the Texture Stage States. And I fear that until André Lamothe''s Volume II of his great Direct X book is out.... So my question is this.. is there any way to use single pass texturing to apply a mask to a bitmap and have the result identical to the above (Alpha blended on a per pixel basis... replaces ColorKeying and allows for some nice effects). While we''re at it.. any way that Multi-pass texturing could work if single pass won''t? Thx a million in advance for any type of answer concerning this... should you need an source example, let me know. Rej

Share this post


Link to post
Share on other sites
Advertisement
I have actually been trying to figure out how to do a per pixel alpha blend myself...i have posted a couple different messages but havent had a response yet...where did you find out how to do yours? and is there a tutorial for something simple and basic? btw why not use a targa image and save an alpha channel directly into the image itself? any tips or suggestions would be appreciated...i myself have also just started into D3D after playing and learning the 2D DirectDraw stuff

Share this post


Link to post
Share on other sites
I learned about it in a SDK sample called DxTex found in the following directory...

X:\Ms_SDK\Samples\Multimedia\DDraw\Src\DXTEX

It''s a tool offered by microsoft used to convert bitmaps into different texture formats. In it I found how to import the alpha channel from another bitmap and also how to do the blit (partly.. there are other good samples found here for alpha blending blits using D3D).

Hope this helps.. let me know if you have any other questions.

Rej

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!