Jump to content
  • Advertisement
Sign in to follow this  
Ailus

Combining both Vertex and Texture Alpha Operations...

This topic is 4054 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

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:
	struct CUSTOMVERTEX
	{
		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_ALPHAOP,D3DTOP_SELECTARG1);
	//m_pD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1, D3DTA_TEXTURE); IGNORE
	m_pD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
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)/2);
or
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
Advertisement
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!

Cheers!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!