Jump to content
  • Advertisement
Sign in to follow this  
Dawid Zwiewka

OpenGL Triple multiply blending in DX

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


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);

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:


SRGBA = Arg1 + Arg2 * Arg3


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.


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!