Advertisement Jump to content
Sign in to follow this  

No alpha :(

This topic is 4980 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 guys, No matter what I've tried, my mesh won't render with alpha. 1. My texture being set has alpha and sets (all validated). 2. Set all my texture stages correctly to use alpha from vertices and texture. (edit) Vertices also have alpha on them set to 0x55FFFFFF. 3. Disable shaders so its purely fixed-function. 4. Disabled lighting. 5. My FVF contains diffuse and all validated, all ok. 6. Debug DLL's and debug run doesnt complain of anything. 7. My mesh renders with alpha for the VERY FIRST FRAME ONLY when i use the REF driver. 8. Code can be found at: Absoloutey any idea why my mesh will not render with alpha? Thanks, MeshMan

Share this post

Link to post
Share on other sites

1) Ensure that all alpha polygons are drawn after all opaque polygons.

2) SetRenderState(D3DRS_ZWRITE, FALSE) so that the rendered alpha polygons don't write to the Z buffer.

3) Ensure you're clearing the frame buffer and Z buffer in your Clear() call.

Share this post

Link to post
Share on other sites
Ok. Disabled my GUI system drawing and it comes out fine.
Still can't figure out why though...
Heres my GUI Render routine:

if (!m_pStateBlock || !m_pMaterial || !m_pSprite)

D3DDevice *pDevice = Engine::GetInstance().GetDevice();



pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);

pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);


pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);



if (m_pActiveDesktop)


Share this post

Link to post
Share on other sites

1) ID3DXSprite does set a whole bunch of render state, it's probably worth checking the list in the docs to see that none of it is interfering with your state.

2) What's recorded in m_pStateBlock? - in particular anything enabling shaders or changing any of the MATERIALSOURCE or COLORWRITEENABLE render states?

[EDIT - missed the reply - Old advice:]
Can you post the structure of "FontVertex" - when using fixed function, the layout of the components in a vertex must be in a very specific order - if they're not in the right order, you may find colour being interpreted as say a texture coordinate...

Setting the clear colour to something like bright pink is a good idea too - so you can see black polygons and tell for certain which ones blending is occurring on.

BTW: you are Clear()ing every frame aren't you?

BTW2: Just to confirm, the mesh does render doesn't it - just without any transparency?

Share this post

Link to post
Share on other sites
Yes im clearing and the mesh does/did render without the alpha.

I'm wondering if its that silly state block messing my states up...always been cautious about them and it seems they are messing with states.

Share this post

Link to post
Share on other sites
What stuff have you recorded into the state block? - and importantly, how and when was it recorded?

If it was at a time when shaders were active or the color write or material sources were set to something strange, then that's a likely target.

Do remember that some device drivers aren't so careful about setting render states to their default, so if you're using a PURE device and assuming "default" state will be recorded, then that can be a problem. Ideally set *all* render states and texture stage states to a sensible default for your app when it starts up, and definately before recording any state blocks.

Share this post

Link to post
Share on other sites
Ok. Will implement that right away.
Thanks for your help.

I wasn't capturing my state block at the start of my GUI rendering function like I should of done. I've now added the capture and it all works fine.

Sorry for the inconveinience but sometimes I'm just not aware of what can be messing about with the states.

Live and learn I guess.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!