Jump to content
  • Advertisement
Sign in to follow this  

[Resolved]Alphablended polygon has alpha, but if I set a texture, alphablending fails

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

Hey everyone, I seem to have an odd problem. Lets say I have created a triangle with 3 vertices, each vertex is colored RGBA(255,255,255,128). When rendered on a black background, it appears as grey, scince it is blended. But, if I set a texture and then render the triangle, it is rendered as if alpha blending is disabled. But alpha testing still works. Has anyone had this problem before? Any ideas? [Edited by - CadeF on January 9, 2006 9:19:19 AM]

Share this post

Link to post
Share on other sites
I'm using the default sampler state.

All alpha-related code I'm using (VB.NET,MDX) -

D3DDevice.RenderState.AlphaBlendEnable = True
D3DDevice.RenderState.SourceBlend = Blend.SourceAlpha
D3DDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha

D3DDevice.SetTexture(0, DXTexturePool(DXGetTextureIndex("Particle.png")).Tex)
DXRender2DBox(0, 0, 512, 512, Color.FromArgb(32, 255, 255, 255).ToArgb, 0)
Vertices are created with varying XY positions, Z=0, Rhw=1, U,V (TransformedColoredTextured)

I'm not sure what I could be doing wrong.

Edit: Btw, color keying works.

[Edited by - CadeF on January 9, 2006 4:45:05 AM]

Share this post

Link to post
Share on other sites
I never used MDX but this is what i'd do in C++:


m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );

m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );

m_pd3dDevice->SetTextureStageState( dwStage, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( dwStage, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( dwStage, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

m_pd3dDevice->SetTextureStageState( dwStage, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( dwStage, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( dwStage, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );

The texture stage has been renamed sampler state in DX9. This takes both the color of the texture and the diffuse color, modulates them and then blends the result onto the surface.

Share this post

Link to post
Share on other sites
For I = 0 To 8 - 1
With .TextureState(I)
.ColorOperation = TextureOperation.Modulate
.ColorArgument1 = TextureArgument.TextureColor
.ColorArgument2 = TextureArgument.Diffuse

.AlphaOperation = TextureOperation.Modulate
.AlphaArgument1 = TextureArgument.TextureColor
.AlphaArgument2 = TextureArgument.Diffuse
End With

Thanks, works now. :)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!