Archived

This topic is now archived and is closed to further replies.

Xeno

Fade In/Out Effect

Recommended Posts

hi, im trying to implement the fade in/out effect using Dx8 Vertex buffers, but it seems to be very sloww coz i have to Lock/Copy/Unlock the vertices data each time im changing the alpha channel value... is there any other way to do it?

Share this post


Link to post
Share on other sites
Yes.. indeed. You can manipulate the gammaramps on your 3d-hardware directly in your code. This is pretty fast, but you are limited to simple fades (like fade to black).

Although I haven''t tried it, it should be possible to implement a fade using maps (like light/dark-mapping(modulating)), without locking/unlocking the vertexbuffer each frame.

Erik

Share this post


Link to post
Share on other sites
You can also use texture stage alpha functions to adjust alpha so you don't have to lock/unlock vertices.


m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );

m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
m_pd3dDevice->SetRenderState(D3DRS_TEXTUREFACTOR, dwTransparency);


[edited by - nPawn on December 25, 2002 11:38:52 AM]

Share this post


Link to post
Share on other sites