Triple multiply blending in DX

Started by
-1 comments, last by Dawid Zwiewka 10 years, 4 months ago

Hi.

I'm trying to do something exactly the same as it's in OpenGL. I made some tests and it looks that when I write glBlendFunc(GL_SRC_COLOR, GL_ONE) it takes color*alpha from texture. The same code in DX:

pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR ));
pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE ));

takes just color from texture.

Example: i got 0x00ffffff color on texture. OpenGL render it as fully transparent and DX render as white. I wrote something like this:

pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE | D3DTA_ALPHAREPLICATE);

It works perfectly, just the same way as OpenGL does. BUT... Now i can't use diffuse color as both color args are in use already. I know there is also COLORARG0 but there is no operation arg0*arg1*arg2 in DX. I found only this:


D3DTOP_MULTIPLYADD

SRGBA = Arg1 + Arg2 * Arg3

D3DTOP_LERP

SRGBA = (Arg1) * Arg2 + (1- Arg1) * Arg3.

None of those allow me to make a1*a2*a3 which I need. The problem occurs in almost all blending combinations. I can't simply not use those combinations because they are already used in games which use engine which I'm porting to DX. There is also something like premodulate but I'm not sure how it works and can't find any explanation or examples.

I'm waiting for any clues.

This topic is closed to new replies.

Advertisement