Jump to content
  • Advertisement
Sign in to follow this  
veyix

Incorrect Geometry When Enabling Alpha Blending

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

[font="Arial,"]I have a test application with enabled transparency achieved through alpha blending. The application is built in C# using SlimDX. However, on one of my objects that has alpha blending applied, I am getting a strange 'missing triangle' effect (see below).[/font]
[font="Arial,"]
[/font]
[font="Arial,"]W2kLs.png
[/font]
[font="Arial,"]
[/font]
[font="Arial,"][size="4"]The object is almost a cylinder.[/font]

[font="Arial,"][size="4"]I wondered if anyone more experienced in 3D computer graphics and/or the use of alpha blending might be able to point me in the right direction so I might understand this result - and hopefully remove it.[/font]

[font="Arial,"][size="4"]I have tried to use an order independent blending shader and I get the same result. It would appear as though the pixels/fragments are being discarded due to failing the depth test. This does not make any sense to me.[/font]

Share this post


Link to post
Share on other sites
Advertisement
Even though a given pixel is transparent (alpha < 1.0), its depth is written to the depth buffer. The depth buffer does not care about the opacity used in blending; if you draw something "behind" the current pixels, it will be discarded. The randomness simply shows that the geometry data is a random order.


There are ways to circumvent this:

-Use additive blending, and disable depth write. This way, the order of the triangles do not matter.
-or-
-Sort the geometry back to front (per-poly sorting can be slow though)
-or-
-Use a technique called "depth peeling" (google this for examples)
-or-
-Store the pixels with depth data to a stack buffer, and sort them upon drawing time (requires SM5 hardware)

Also, "order independent blend shader" does not make much sense. These techniques are combinations of shaders, blend states and depth/stencil states.

Share this post


Link to post
Share on other sites
My first guess on looking at the image is that the artefacts are caused by the z-buffer. I suspect you have two objects there, and it looks like only one is transparent.

I'd suggest using PIX (which comes with the DirectX SDK) to debug it.

Share this post


Link to post
Share on other sites
[color="#1C2837"]I'd suggest using PIX (which comes with the DirectX SDK) to debug it.[/quote]

I have tried PIX. It told me the pixels in question had been discarded.

[color="#1C2837"]Also, "order independent blend shader" does not make much sense.[/quote]
[color="#1C2837"]
[color="#1C2837"]Apologies - I meant that I had tried to create a shader that employed an Order Independent Transparency technique. I have actually been researching Depth Peeling for about the last 3 months. So far, I have made one attempt at actually creating a project that uses a Depth Peeling shader, but it did not solve my issue. I assume it didn't solve the issue because it was not completed correctly.
[color="#1C2837"]
[color="#1C2837"]I have also tried additive blending, which I noted did solve the issue. However, it caused the final render to be too bright, so it was not a suitable solution.
[color="#1C2837"]
[color="#1C2837"]I will try to order the vertices by depth and see what results I get.

Share this post


Link to post
Share on other sites
Also note what Adam_42 said. He might be on to something as well.

With PIX you can get the pixel history of any pixel on the render target. Get the histories of two pixels that behave differently (one lighter, one darker) and investigate why one of them was discarded while the other was preserved.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!