Object Behind The Blending Transparency Clipped

Hello, try to play with blending alpha function in GLSL. I got the window glass transparent.

If I render the object ordered by:

  1. Building, car, window, skybox, I can look through the window and the building and the car, while the skybox clipped.
  2. Window, building, car, skybox, the building, car, and sky are clipped.
  3. Skybox, building, car, window, I can look through the window correctly, no models are clipped.

Picture companion:

  2. http://s25.postimg.org/fhe9pjpy7/Incorrect_2.jpg
  3. http://s25.postimg.org/xhngtxi5b/Correct.jpg

Thank you.

By “clipped”, I presume that you mean “discarded by depth testing”.

If you render the window with depth writes enabled, then it will update the depth buffer, and any farther objects will fail the depth test.

If you render the window with depth writes disabled, then it won’t update the depth buffer, and any objects drawn after the window will overwrite it, regardless of whether they’re nearer or farther than the window.

In order for translucency to work correctly, it’s necessary to render the translucent surface after any opaque surfaces.

If you have multiple translucent surfaces, they have to be rendered in the correct order; if surface A is in front of surface B, A must be rendered after B. This can be done using a topological sort, or a BSP tree. For complex geometry, it’s typical to perform the sorting on a per-pixel basis using depth peeling or by storing a linked-list of fragments for each pixel.

Thanks for the clear explanation, GClements :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.