Archived

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

NotTaxes

SetTextureStageState and Texture Blending

Recommended Posts

OK, I''m really struggling here. Previously I was using multiple passes to merge textures (pass1 paints a texture, then pass2 paints a texture with an alpha-channel for transparency). Now it looks like I could have up to 4 textures on the same polygon so I looked for a better way to do this. From what I can gather, using texture stages is a reasonable way forward, but the problem is that I just can''t fathom the cursed SDK documentation about texturestagestates. The only result I seem to get is a big fat nothing. Can anyone give me a 10line code snipet for blending two textures (with transparencies) or perhaps point me to a decent tut? Thanks in advance I have plenty of talent and vision, I just don''''t give a damn.

Share this post


Link to post
Share on other sites
Mr-gamemaker had a very good tutorial but I haven''t checked if it still is there.... Here is the address...
www.mr-gamemaker.com

Share this post


Link to post
Share on other sites
Thanks Pexi, but no luck there it would seem. How about even just an algorythm? Anyone?

I have plenty of talent and vision, I just don''''t give a damn.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
This will blend 2 textures together. Make sure to have a second set of UVs set if you wanna use different ones for the 2nd texture.

g_pd3dDevice->SetTexture( 0, g_pTexture1 );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_ANISOTROPIC );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_ANISOTROPIC );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );

g_pd3dDevice->SetTexture( 1, g_pTexture2 );
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE2X);
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_MINFILTER, D3DTEXF_ANISOTROPIC);
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTEXF_ANISOTROPIC);
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP );
g_pd3dDevice->SetTextureStageState( 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP );

Share this post


Link to post
Share on other sites
Thank you, Anonymous Person! Now all of those args and vals make sense :-)

I have plenty of talent and vision, I just don''''t give a damn.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You''re welcome.

Anonymous Person.

Share this post


Link to post
Share on other sites
G''day!

There aren''t many cards that will support 4 level multi-texture (GeForce3 & Radeon?). Your best bet is probably to use multi-pass & 2-level multi-texture since virtually everything supports 2 texture stages. That way you only do 1 pass for 1 or 2 textures, 2 passes for 3-4.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Thank you Drunken Hyena... the thing is that I am trying to create composite textures using one as a ''carving'' tool that can be applied to ''material'' texture. Using multiple passes doesn''t do this quite right while multi-texturing does. But you reckon I''ll be OK if I stick to 2 stages?

I have plenty of talent and vision, I just don''''t give a damn.

Share this post


Link to post
Share on other sites