Jump to content
  • Advertisement
Sign in to follow this  
briantsim

Texture Alpha Channels Problem?

This topic is 4248 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!