Jump to content

  • Log In with Google      Sign In   
  • Create Account


Trouble with AlphaState


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 codymanix   Members   -  Reputation: 132

Like
0Likes
Like

Posted 19 January 2013 - 04:55 PM

Hi Iam having trouble getting transparent texture to work correctly. I append what the problem is.

error.png

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.

Attached Thumbnails

  • error.png

Edited by codymanix, 19 January 2013 - 05:31 PM.


Sponsor:

#2 eppo   Crossbones+   -  Reputation: 2406

Like
1Likes
Like

Posted 20 January 2013 - 03:57 AM

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.



#3 codymanix   Members   -  Reputation: 132

Like
0Likes
Like

Posted 20 January 2013 - 12:27 PM

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?



#4 eppo   Crossbones+   -  Reputation: 2406

Like
1Likes
Like

Posted 22 January 2013 - 03:00 AM

The Xbox supports a variation of shader model 3.0.

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS