Jump to content
  • Advertisement
Sign in to follow this  
codymanix

Trouble with AlphaState

This topic is 2066 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 Iam having trouble getting transparent texture to work correctly. I append what the problem is.

[sharedmedia=core:attachments:13305]

As you can see, the transparency works good for the bottom faces. But the faces in the background are somehow obstructed by the transparent texture although it should shine through. This effect seem always to happen with all faces in this direction, doesnt seem to happen with faces pointing in the other direction. What could this strange effect be?

Iam using the following (and the BasicShader) to draw things:

CullMode=Off;
FieldOfView = MathHelper.ToRadians(45);
AspectRatio = (float)Engine.Instance.Graphics.Viewport.Width / (float)Engine.Instance.Graphics.Viewport.Height;
NearPlane = 0.1f;
FarPlane = 250.0f; Graphics.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.LightBlue, 1.0f, 0);
Graphics.BlendState = BlendState.AlphaBlend;
Graphics.DrawPrimitives(PrimitiveType.TriangleStrip, cubeSide * 4, 2);

EDIT3: I found that it only happens if I look at a face that is behind, right or top from the cube I am looking at.
It doesn't happen for front, bottom or left faces. Could this have to do something with my normals, since Iam using different geometry for each cube side (6 different Meshes)? Without AlphaBlend everything is rendering fine. I now tried VertexPositionTexure (without normals), still the same problem. Edited by codymanix

Share this post


Link to post
Share on other sites
Advertisement

If you draw each cube side independently, then in what order do your draw your geometry?

Is the the alpha-quad drawn first (with z-writing enabled) and then the stone-quad behind it? In that case you need to either draw the alpha blended geometry last, or use 1 bit alpha-testing for the transparent areas.

Share this post


Link to post
Share on other sites

Hi thanks for the answer!
 

Yes I draw the quads in arbitrary order and with enabled Z-Buffer. Due to the (potentially) huge number of transparent objects I have sorting is no option for me.

But I searched a bit and found out that I can use the AlphaTestEffect or the HLSL Instruction clip().

Is HLSL portable to XBox or Windows Phone?

Share this post


Link to post
Share on other sites

The Xbox supports a variation of shader model 3.0.

Windows Phone 8 can run D3D 11 with feature level 9_3.

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!