Sign in to follow this  

Same Alpha Map for Different Textures ?

Recommended Posts

Hi guys, I'm using D3D for 2D and a lot of my textures use the exact same alpha map; it seems like a waste that each texture has its own alpha channel when they are all the same. Also, it would be nice if I could change the alpha map on the fly. So is something like this possible: BeginScene() for each blit { set alpha map set texture (RGB only, no A) blit } EndScene() That would be great. I'm still pretty new at D3D so maybe it can be done simply. Take care.

Share this post

Link to post
Share on other sites
It should be perfectly possible using pixel shaders; have 2 textures as inputs - one is your alpha channel, and one is your diffuse channel(s). Write the output as being a combination of the two textures.

However, if you don't wanna be messing with shaders...

You can probably do what you want by having multi-texture rendering.

I can never remember the correct ordering/setup of the texture blending operations, but you would have IDirect3DDevice9::SetTexture( 0, my_alpha ) and IDirect3DDevice9::SetTexture( 1, my_diffuse ) and then configure the texture stages so as to blend.

The difficulty is going to be in mixing the file formats. I'm not sure if you'll get away with a D3DFMT_A8 (or similar quantity) in one channel and have it blend correctly with a D3DFMT_X8R8G8B8 or D3DFMT_R8G8B8 texture in the second channel.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this