Sign in to follow this  

Combining both Vertex and Texture Alpha Operations...

Recommended Posts

Hey everyone, Currently I'm making a tiling engine for my game engine (both Isometric and Top-Down modes for maximal expansion of content later on), but I'm stuck with a dilemma: I can't seem to figure out how to set the Texture Stage State so I can both set the Alpha values of a surface (really just two polys to form a quad, not a real DX surface) by both its Texture alpha channel (if it has one) and by its Vertex Alpha Values (If its different from 0xFF). I was trying to find some way to add in vertex alpha values to the CUSTOMVERTEX struct:
		float x, y, z;
		DWORD dwColor;
		float u,v;
but alas nothing worked (I don't think its even possible?). So then I decided to use the regular old diffuse channel approach to vertex alpha blending, and I set it up and it works for the most part, except that it cancels out the Texture alpha blending operations, which I also wanted. Here's what I got for my Texture Stage State:
	m_pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
	m_pD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
	//m_pD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1, D3DTA_TEXTURE); IGNORE
which gives me the effect described above, canceling out the texture alpha channel. So then I tried to get creative by trying to average the ALPHAARG1 settings, such as by doing this:
m_pD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,(D3DTA_DIFFUSE & D3DTA_TEXTURE);
But still nothing worked the way I wanted it to. So here I am now. Basically what I want is to be able to set a quad's (two poly's) alpha values by its Texture if it has an alpha channel and also by the vertexes if I set it differently than 0xFF (or 100% opaque). Anyone have any suggestions or ideas on how to accomplish this?

Share this post

Link to post
Share on other sites
Did you try something like :

m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );

? Texture Alpha * Diffuse Alpha

Share this post

Link to post
Share on other sites
Wow that worked just the way I wanted it to! =] Thanks a bunch!

Guess I missed that option "D3DTOP_MODULATE" in the MSDN libraries. Next time I'll be sure to read up a bit more thoroughly.

Edit: Actually I missed the whole page on D3DTEXTUREOP options. There's so many! Time to have some fun experimenting =P

Thanks again!


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