I'm trying to draw triangles with alpha blending. However, it doesn't seem that the approach I'm trying to take isn't supported:
final alpha = texture alpha x vertex alpha
There are two material options which do each one separately, but don't modulate them together. EMT_TRANSPARENT_ALPHA_CHANNEL and EMT_TRANSPARENT_VERTEX_ALPHA.
Is there a trick I don't see, or is it not yet supported?
Alpha Blending with Texture and Vertex
heh, i looked for this type of material too... finishing by adding my own material. it is easy. DX8/9. It would be great to find OpenGL analog!
Main method (other are obvoius)
Alpha-enabled texture is blended with vertex color alpha
Main method (other are obvoius)
Code: Select all
void CSpriteMaterial_Transparent::OnSetMaterial(irr::video::SMaterial& material, const irr::video::SMaterial& lastMaterial, bool resetAllRenderstates, irr::video::IMaterialRendererServices* services)
{
services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType
|| material.MaterialTypeParam != lastMaterial.MaterialTypeParam
|| resetAllRenderstates)
{
if(pID3DDevice8){
{
pID3DDevice8->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
pID3DDevice8->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pID3DDevice8->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pID3DDevice8->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
pID3DDevice8->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pID3DDevice8->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
pID3DDevice8->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
pID3DDevice8->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
pID3DDevice8->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pID3DDevice8->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pID3DDevice8->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
}
}
}