[Resolved]Alphablended polygon has alpha, but if I set a texture, alphablending fails
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]
How are your render states and texture stage stages (sampler states as of DX9) set up?
Esp. are you modulating texture and diffuse or simply selecting one of them?
Esp. are you modulating texture and diffuse or simply selecting one of them?
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]
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]
I never used MDX but this is what i'd do in C++:
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.
DX8: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.
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
Next
Thanks, works now. :)
With .TextureState(I)
.ColorOperation = TextureOperation.Modulate
.ColorArgument1 = TextureArgument.TextureColor
.ColorArgument2 = TextureArgument.Diffuse
.AlphaOperation = TextureOperation.Modulate
.AlphaArgument1 = TextureArgument.TextureColor
.AlphaArgument2 = TextureArgument.Diffuse
End With
Next
Thanks, works now. :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement