Weighted blended OIT issue. Transparent objects are visible through opaque ones

I have been trying to implement Weighted Blended OIT from LearnOpenGL - Weighted Blended.

So the blending works correctly with one issue, when the transparent objects are behind opaque ones (but also other transparent ones), the transparent ones are see through.

First two images. Red and blue are opaque and green is transparent. All transparent objects have alpha of 0.5. When transparent object is in front it blends correctly. But it is visible through the opaque objects in the second picture.


Two more images where red is opaque and blue and green transparent. Green is visible through both transparent blue and opaque red in the second image.


I have reread my code hundreds of times and can’t find the issue. It is either I made a typo somewhere while following the guide, or the code in guide itself has a mistake somewhere.

I wonder if it’s possible to tell what could be the problem without pasting hundreds of lines of codes here.

GL Version: 4.6 (Core Profile) Mesa 22.1.6

If you want the translucent primitives to be obscured by opaque primitives, the opaque primitives need to be drawn first with depth writes and tests enabled and the translucent primitives drawn last with depth tests enabled.

If you’re including opaque primitives in the blending process, then nature of order-independent transparency is that it’s, well, order-independent. It doesn’t care whether primitives are behind or in front of other primitives.

I’m not including opaque objects into the blending process. The way the technique (Weighted Blended) was presented on the website, is that the opaque objects are drawn into a framebuffer (lets call it opaque framebuffer). Then translucent objects are drawn into two separate textures in a separate framebuffer (translucent framebuffer). And then we composite the two.

So the issue is not with this.