Archived

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

SoRich

Separate Rendering on Fixed Pipeline

Recommended Posts

Hello all. I have 2 textures with color and some alpha chanel data. And i must to blend it in next way some factor; result.color = tex1.color * (factor) + tex2.color * (1- factor) result.alpha = tex1.alpha * (factor) + tex2.alpha * (1- factor) Anybody know, can I did it on fixed pipeline? Thanks in advanse! Andriy Sorich

Share this post


Link to post
Share on other sites
Sure. Check out the mfctex example.

You want to use SetTextureStageStat() to set multitexture blending (modulation, addition, etc). You can do this independantly for the rgb channels and alpha channel. For the factor, check into D3DRS_TEXTUREFACTOR and D3DTOP_BLENDFACTORALPHA.

---
http://www.gapingwolf.com

Share this post


Link to post
Share on other sites
Yes.
I''m doing so, but it looks strange:

SD3dDeviceI->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
SD3dDeviceI->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
SD3dDeviceI->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);

SD3dDeviceI->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
SD3dDeviceI->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE);
SD3dDeviceI->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_ONE);

SD3dDeviceI->SetRenderState(D3DRS_TEXTUREFACTOR, factor);

SD3dDeviceI->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
SD3dDeviceI->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
SD3dDeviceI->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDFACTORALPHA);
SD3dDeviceI->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
SD3dDeviceI->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);

SD3dDeviceI->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
SD3dDeviceI->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
SD3dDeviceI->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_BLENDFACTORALPHA);
SD3dDeviceI->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
SD3dDeviceI->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);

Share this post


Link to post
Share on other sites