diff --git a/src/effect/efimage.cpp b/src/effect/efimage.cpp index 83478d0b..bafdf10d 100644 --- a/src/effect/efimage.cpp +++ b/src/effect/efimage.cpp @@ -246,7 +246,7 @@ class BlendColorImage : public WrapImage { void Render(Context* pcontext) { WrapImage::Render(pcontext); - pcontext->SetBlendMode(BlendModeSourceAlpha); + pcontext->SetBlendMode(BlendModeSourceAlphaPreMultiplied); pcontext->FillRect(GetBounds().GetRect(), GetColor()->GetValue()); } }; diff --git a/src/engine/RasterD3D9.cpp b/src/engine/RasterD3D9.cpp index 9fd11c99..d4eab949 100644 --- a/src/engine/RasterD3D9.cpp +++ b/src/engine/RasterD3D9.cpp @@ -300,6 +300,14 @@ class D3D9RasterizerImpl : public D3D9Rasterizer D3DCall(CD3DDevice9::Get()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA)); break; + case BlendModeSourceAlphaPreMultiplied: + CD3DDevice9::Get()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + CD3DDevice9::Get()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); + D3DCall(CD3DDevice9::Get()->SetRenderState(D3DRS_ALPHABLENDENABLE, true)); + D3DCall(CD3DDevice9::Get()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE)); + D3DCall(CD3DDevice9::Get()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA)); + break; + default: ZError("Invalid BlendMode"); diff --git a/src/engine/context.cpp b/src/engine/context.cpp index 01ecd96c..5c391799 100644 --- a/src/engine/context.cpp +++ b/src/engine/context.cpp @@ -701,6 +701,13 @@ class ContextImpl : public PrivateContext { pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); break; + case BlendModeSourceAlphaPreMultiplied: + pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); + pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, true); + pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + break; default: ZError("Invalid blend mode"); } @@ -987,6 +994,13 @@ class ContextImpl : public PrivateContext { pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); break; + case BlendModeSourceAlphaPreMultiplied: + pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); + pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); + pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, true); + pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + break; default: ZError("Invalid blend mode"); } diff --git a/src/engine/context.h b/src/engine/context.h index c0f61083..59ea825d 100644 --- a/src/engine/context.h +++ b/src/engine/context.h @@ -662,7 +662,8 @@ enum ShadeMode { enum BlendMode { BlendModeSource, BlendModeAdd, - BlendModeSourceAlpha + BlendModeSourceAlpha, + BlendModeSourceAlphaPreMultiplied }; enum WrapMode {