Sign in to follow this  
briantsim

Texture Alpha Channels Problem?

Recommended Posts

Hi all, I drew 3D Model(*.x) in my Game. But some alpha channels has problem with display. Below is my problem screen and model texture. Please somebody tell me what is my problem. My Problem Screen: http://hk.geocities.com/brian_tsim/problem.html Best Regards, [Edited by - briantsim on November 27, 2006 3:50:23 AM]

Share this post


Link to post
Share on other sites
You have a problem with the depth buffer. When a pixel is drawn it blocks all the pixels behind it. That's true even if it's a transparent pixel. There are several ways to solve this.

If you're just using opaque and transparent and no intermediate values, using alpha testing is an easy way to solve the problem. It simply doesn't draw pixels with certain alphas (such as alphas under a value you set). Implementing alpha testing is easy, and should improve things considerably, so I'd suggest that you start with this.

Normally when drawing with alpha, you also want to draw from back to front. You'd render all the non-alpha geometry first, then sort the object with alphas and draw from back to front. This is not only to solve the depth problem but to get the correct colours when blending.

Share this post


Link to post
Share on other sites
Hi, devronious & ET3D

Thanks for you help,But i not very understands, what is mean by alpha testing, I tried search wtih google. Alpha testing whether software? How to test alpha? Can you give me some detail information?

Share this post


Link to post
Share on other sites
Alpha testing is where the alpha value is compared against some value. If the test passes, the pixel is rendered. If the test fails, the pixel is not rendered, skipping both color and depth/stencil writes.

in code
SetRenderState(D3DRS_ALPHATESTENABLE, true);
SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
SetRenderState(D3DRS_ALPHAREF, 128);

in an FX file
AlphaTestEnable = true;
AlphaFunc = GreaterEqual;
AlphaRef = 128;

This says to keep any pixel who's alpha is greater or equal to 128.

This can be used alone, to create shapes, often used for sprites, fonts, leaves and grass. It can also be used together with alphablending as a speed boost (there is no point in blending when the alpha is tiny, as the effect won't be noticable).

Share this post


Link to post
Share on other sites
briantsim, I don't know if you're using managed or C++, but in the C++ docs, typing "alpha testing" in the index will bring you a page about that. It's not a very good page, and what Namethatnobodyelsetook said will give you the right start, but I'm just mentioning it because it's a good idea to check out the C++ docs if you want to learn something. The managed docs, if that's what you use, explain less.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this