No alpha :(

Started by
6 comments, last by MeshMan 18 years, 11 months ago
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: http://rafb.net/paste/results/vAjpdH96.html Absoloutey any idea why my mesh will not render with alpha? Thanks, MeshMan
Advertisement
Try:

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.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Check, Check and Check.

Nothing different.
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)			return;		D3DDevice *pDevice = Engine::GetInstance().GetDevice();		m_pMaterial->Select();		pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);		pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);		pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);		pDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);		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->SetVertexShader(NULL);		pDevice->SetPixelShader(NULL);		pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);		pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);				m_pSprite->Begin(D3DXSPRITE_DONOTSAVESTATE | D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE);							GUIBase::Begin();		if (m_pActiveDesktop)			m_pActiveDesktop->Render();		m_Mouse.Render();				GUIBase::End();		m_pSprite->End();		m_pStateBlock->Apply();

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?

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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.
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.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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.

This topic is closed to new replies.

Advertisement