All.
I must be with stupid, cuz multitexture blending is an old topic, and it seems simple enough, but I must be missing something...
I'm basically trying to do what other's have done before me: Blend two textures so that I don't have to make transition tiles(ie, grass to sand, sand to water)
I'm using two graphics files,
grasstrans.png - grass texture with a gradient alpha channel
sand.png - sand texture with a solid alpha channel
The sand.png is in texture stage 0(m_pBaseTexture)
The grasstrans.png is in texture stage 1(m_pBlendTexture)
They are set every render phase:
if (m_pBaseTexture)
g_pDevice->SetTexture(0, m_pBaseTexture);
if (m_pBlendTexture)
g_pDevice->SetTexture(1, m_pBlendTexture);
And in my initialization phase, I have the following:
m_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
m_pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
m_pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
m_pDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_BLENDTEXTUREALPHA);
m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
m_pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
I explicitly set everything, just to make sure that it's doing what I want. However...it's not. Even if I exchange the places of the textures in the texture cascade, and I change stage 1's(The second stage)alpha operation to D3DTSS_SELECTARG2, I just get a gradient alpha of the sand.png average COLOR, but not the sand texture. And in any case, it seem like I can only see the texture of only stage 0(the first stage).
Oh yeah...and my video card should support multitexturing(since I was able to do operations on colors, just not the alphas), and all the diffuse colors in the verticies are set to opaque white(255,255,255,255)
What am I missing? Maybe the entire approach is wrong? Thanks in advance for anyone that can knock the stupid out of me.
Wil
Edited by - iamwil on December 13, 2001 10:10:32 AM
Edited by - iamwil on December 13, 2001 10:17:33 AM