🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Direct3D Textures with alpha components

Started by
4 comments, last by Facehat 24 years, 8 months ago
I have never encountered anything on that subject, either in the SDK or in any game programming article. That would consume a great deal of processor cycles would it not?

You could possibly simulate various transparency levels by modifing the color of each pixel to be, say, less intense (for a more transparent colour - red becomes pale reddish-pink etc) or more intense (for greater opacity).

Other than that I believe you could store 'pixel' information with your texture (a vector or list that holds only pixels with varying transparency). This would force you to use your own alpha-blitter though - which is probably what you are trying to avoid right?

Advertisement
Look in the docs under Direct3D\Direct3D Immediate Mode Essentials\Textures\Texture Blending\Alpha Texture Blending
I just figured that one out
When you enumerate texture formats (this is assuming 16 bit pixels) you should get one with a pixel format that has 4 bits in the bitmask for each r,g,b, and alpha component (4,4,4,4). By creating a texture using this pixelformat, and setting the 'a' component between 0x0 and 0xF (totally transparent vs. totally opaque), you get pixel by pixel transparency. This apparently only works right if you draw all the transparent polygons after all the totally solid ones, and draw the transparent ones from back to front while hopping one one foot (preferably the right foot, unless CULLMODE is set to clockwise).
This is assuming you're loading your own textures yourself (i.e., opening the BMP file and reading in the bytes), I dont know how you'd set the alpha using windows' bitmap functions. Also, there are other alpha formats besides the 4,4,4,4.
Hmm I had a site here with a good example of this alpha stuff...

AHA!
http://www-cs.intel.com/design/graphics/applnots/alphabln.htm

And the code is at:
http://www.intel.ie/design/graphics/740/swdev/sdk/ablend3d.htm

Yeah yeah its for an older card, but most of it still applies.


-ns

-ns-
Thanks for all the responses . It doesn't sound like this is possible through D3DX though . Or is it? Does D3DX automatically make 4x4x4x4 textures if the device supports it? (assuming your running in 16bit color)

--TheGoop

Hi everyone,

I've been trying to think of how to use textures with each pixel having its own alpha component (for instance, maybe pixel 1 might have 50% transparency while pixel 99 has 75% transparency). Anyway, I went to the all knowing source of great information, err, the SDK Documentation . But the all knowing source of information had no information on the subject.

Does anyone know how would I do this? Is it in the SDK Docs and I just missed it? What if Elvis is alive, and were all dead? If a tree fell on Richard Simmons, would anyone care?

The truth is out there

--TheGoop

Check out the DirectX Texture Tool that came with the DX SDK. It does all sorts of things useful to 3D textures (alpha channel, mip-map generation) and saves to its own file format (.DDS) which D3DX does support in loading.

This topic is closed to new replies.

Advertisement