how can i use directx render a alpha picture?

Started by
0 comments, last by Tsus 12 years, 3 months ago
when i load a png picture with alpha channel,i use the code below:
Device->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
Device->SetRenderState(D3DRS_ALPHAREF, 0x20);[attachment=6475:dx.png]
Device->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
to render the picture on a vertexbuffer quad.its effect like this:(the dx.png)
[attachment=6475:dx.png]
and i rerender it in xna with default settings
[attachment=6476:xna.png]
why is there has a so huge difference??how can i render the effect like xna with my dx(direct3d)??
thx a lot!!!
Advertisement
You used the alpha test which makes a binary decision whether a pixel is discarded or not, so the transparency is either zero or one. If you want to have values in between zero and one you have to use alpha blending instead. In the documentation you find some more information on its parameters Blend and BlendOp, as well. (In case you like to experiment with other blending operations than conventional transparency.)

This topic is closed to new replies.

Advertisement