Skip to main content
GameDev.net gamedev.net
🔒 Locked

alpha problem

Started by MrTheMan Oct 29, 2004 at 1:37 PM 2 replies 650+ views
Original Post
MrTheMan
MrTheMan
I made a program to show models from files, and some object to be transparent, so I added D3DFVF_DIFFUSE to my vertex FVF, and added these lines to my initialization code: m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true); m_d3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); m_d3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); m_d3dDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE); But now I have a problem, I don't know how to describe it but here are some screenshots: without alpha: http://home.hccnet.nl/borre.mosch/screenshot1.jpg with alpha: http://home.hccnet.nl/borre.mosch/screenshot2.jpg Some triangles aren't only transparent, but also make whatever is behind them appear transparent. Does anyone know what I'm doing wrong? Thanks in advance -Borre Mosch
DrunkenHyena
DrunkenHyena
The invisible triangles are still writing to the Z Buffer which may be occluding triangles behind it. Try enabling Alpha Testing.
Stay Casual,KenDrunken Hyena</FON
Sr_Guapo
Sr_Guapo
Do you have a z-buffer set up? If so, you may be drawing the invisible triangles first, then the visible ones, so the visible one aren't drawn becaus they are behind the other tri. Try out DrunkenHyena's suggestion...
Sean Henley [C++ Tutor]Rensselaer Polytechnic Institute
MrTheMan
MrTheMan
Thanks for the replies, yes I have set up a z-buffer set up.
So, following your instructions, I put this in the initialization code:

m_d3dDevice->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x0000001);
m_d3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
m_d3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);

But this doesn't change a thing...do you have any other suggestions or am I doing something wrong?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.