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

Alpha Bypassing

Started by L_dot_N Dec 3, 2002 at 5:33 AM 1 replies 300+ views
Original Post
L_dot_N
L_dot_N
I want to write to the AlphaChannel(Deep,...) and use Opcity(8 Bit SrcAlpha + InvScrAlpha) in a single pass. Has anyone done ist ?? I have done this before, but in a bad hack. I am rendering the scene into a texture. Setting the texture i am rendering in stage 0 and the base texture in Stage 1. Then im am "lrp" tex0.rgb and tex1.rgb by tex1.a. Then setting alpha to the value i want. It works but is not nice to read a texture witch is the aktuell rendertarget. And don´t try to EMBM the input tex0, maybe it works(ATI) but most times you see the titels, or artifacts. Has anyone a better idea for this ???
mdias
mdias
First change the alpha channel of the material being used by
the mesh. Then make the following:

  
p_D3Ddevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
p_D3Ddevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
p_D3Ddevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );


pMeshMaterials[0].Diffuse.a = 0.5f; //Set the opacity of the mesh

p_D3Ddevice->SetMaterial( &pMeshMaterials[0] ); //Set the material being used to render the mesh

p_D3Ddevice->SetTexture( 0, pMeshTextures[0] ); //Set the texture being used to render the mesh

pMesh->DrawSubset(0); // Render the mesh;




Kamikaze
L_dot_N
L_dot_N
I ment I want to use the alpha channel for ohter thing than Opcity
By using
"p_D3Ddevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );"
I have Opctiy Alpha in the Rendertarget, but I want deep in alpha channel in a singel pass.

Topic Locked

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

Sign in to reply to this topic.