Archived

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

softimage

how to use alpha test on rendertarget?

Recommended Posts

The dxsdk is a bit confusing, so I come to ask here. I want to blend a texture onto the rendertarget surface where I already have put something on. Whether an alpha blend or alpha test is OK. How should I setrenderstate and settexturestagestate?

Share this post


Link to post
Share on other sites
If you just want to blend a texture with what''s on the render target, you can do the following:


d3dDevice->SetRenderState (D3DRS_ALPHABLENDENABLE, true);
d3dDevice->SetRenderState (D3DRS_SOURCEBLEND, D3DBLEND_SOURCEALPHA);
d3dDevice->SetRenderState (D3DRS_DESTBLEND, D3DBLEND_DESTALPHA);


Remember you need a pixel format that employs multiple alpha bits, such as A8R8G8B8, in order to use alpha blending.

For single texture rendering, just do this:


d3dDevice->SetTexture (0, pTexture);


where pTexture is a pointer to your texture.

Best wishes.

Share this post


Link to post
Share on other sites
Do you mean

BeginScene();
SetTexture (0, pTextureBackground);
DrawPrimitive();
SetTexture (0, pTextureOverlay);
DrawPrimitive();
EndScene();

But it grow up to be totally white soon.
It''s ok when I set the two textures onto two texture stages,
and set the stage operations.

Share this post


Link to post
Share on other sites
Hi,
as I understand you, you just want to know the settings for blending two normal textures stages.
I''m afraid this is VB-Code, but you surely will be able to convert it...

d3dDev.TextureState(0).ColorOperation = TextureOperation.Modulate
d3dDev.TextureState(0).ColorArgument1 = TextureArgument.TextureColor
d3dDev.TextureState(0).ColorArgument2 = TextureArgument.Current

d3dDev.TextureState(1).ColorOperation = TextureOperation.Modulate
d3dDev.TextureState(1).ColorArgument1 = TextureArgument.TextureColor
d3dDev.TextureState(1).ColorArgument2 = TextureArgument.Current

you can also use

d3dDev.TextureState(1).ColorOperation = TextureOperation.Modulate2X

or

d3dDev.TextureState(1).ColorOperation = TextureOperation.Modulate4X

if you want the second texture to appear stronger.


Share this post


Link to post
Share on other sites