Jump to content
  • Advertisement
Sign in to follow this  

Backside of transparent textures aren´t visible at certain view directions

This topic is 2585 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

I have a glass prism that is built up by transparent textures and I have
a problem of making the backside of them to be visible from any arbitrary
viewing direction. I use HLSL modify the alpha channel to make
the textures transparent and to view them.

I write the following code in XNA to activate the transparent shader
and to draw the textures on every triangle of the glass prism:

transparencyFx.CurrentTechnique = transparencyFx.Techniques[



graphics.GraphicsDevice.RenderState.AlphaBlendEnable =


graphics.GraphicsDevice.RenderState.SourceBlend =


graphics.GraphicsDevice.RenderState.DestinationBlend =


[color="#0000ff"][color="#0000ff"]foreach ([color="#2b91af"][color="#2b91af"]EffectPass pass [color="#0000ff"][color="#0000ff"]in transparencyFx.CurrentTechnique.Passes)











graphics.GraphicsDevice.RenderState.CullMode =


graphics.GraphicsDevice.VertexDeclaration = vDTexture;




[color="#2b91af"][color="#2b91af"]PrimitiveType.TriangleList, texTriP.GetTexTriPrism(), 0, texTriP.GetLength() / 3);




graphics.GraphicsDevice.RenderState.AlphaBlendEnable =


I then get the following result when I run the application and it
works as properly in these viewing directions for instance:



But when it comes these viewing directions you can see that
two of the backside of the transparent textures in each image
aren´t visible any longer:



Why is that? How come one of the backsides is always visible while
the two others aren´t? I have deactivated Culling completely when I
am drawing the glass prism. How do you make every backside visible?

Share this post

Link to post
Share on other sites
Thing is, every time you want to render some transparent/semitransparent (using alpha-blend) models, you have to sort them 1st. You have to sort them by the distance from the camera, and then draw them backwards.

So.... you draw all your opaque models. Sort the transparent models/meshes/MeshParts/polygons , whatever they are . You turn on alpha blending, draw them backwards, and then turn off alpha blending.

Have a look at this.

Or you can can do as i did.
Using a two pass rendering technique. You need a bit of knowledge about shaders.

* Pass 1: draw the solid part: alpha blending disabled, alpha test set to only accept the 100% opaque areas, and depth buffer enabled
* Pass 2: draw the fringes: alpha blending enabled, alpha test set to only accept pixels with alpha < 1, depth buffer enabled, depth writes disabled

Share this post

Link to post
Share on other sites
Yepp, it did work when I tried with the first solution by deactivating the
DepthBufferWriteEnable when drawing the transparent glass prism! =)

Thanks a million! =D

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!