<p>(Promoting comment to answer)
Do the faces have the same alpha value? That might generate the same coverage mask for the surfaces and, hence, only the closest one would be seen.</p>

CC BY-SA 4.0
2019-01-31T12:54:18.363Z
2019-01-31T12:54:18.363Z
Simon F
<p>I am currently looking into alternatives to my current, somewhat slow but exact, OIT approach. Specifically, GL_SAMPLE_ALPHA_TO_COVERAGE to convert the alpha value into a per-sample mask.</p>

<pre><code>// draw opaque objects
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
glEnable(GL_SAMPLE_ALPHA_TO_ONE);
glDisable(GL_CULL_FACE);
// draw translucent objects
</code></pre>

<p>However, if multiple alpha-blended faces are behind one another (such as the back faces which I would want to be visible) I am only seeing the front most one. Is depth testing not done per sample? Can I force it to be done per sample? According to <a href="https://www.khronos.org/opengl/wiki/Depth_Test" rel="nofollow noreferrer">https://www.khronos.org/opengl/wiki/Depth_Test</a> it should already be per sample.</p>

<p>Multisampling is enabled and works fine for everything else (my OIT shaders in fact do sorting per sample which might be a reason for the slowness). The FBO being drawn into is provided by Qt.</p>

CC BY-SA 4.0
2019-01-31T11:55:56.030Z
Not sure exactly what you are doing, but do the surfaces have the same alpha value? That *might* generate the same coverage mask for two surfaces and, hence, only the closer one would be seen.
Simon F
CC BY-SA 4.0
2019-01-31T12:04:57.107Z
@SimonF good idea! yes that is in fact the case, especially with the back faces.
Joe
CC BY-SA 4.0
2019-01-31T12:51:13.157Z
@SimonF After creating my own randomized alpha to coverage shader (writing gl_SampleMask[0]) I can confirm that this solves the issue.
Joe
CC BY-SA 4.0
2019-01-31T12:55:54.803Z
No worries - I had suspicions as, in the past, I once was trying to propose better hardware for "screen door" translucency to address this sort of thing.
Simon F
<opengl><blending>
GL_SAMPLE_ALPHA_TO_COVERAGE and depth testing
Joe
# GL_SAMPLE_ALPHA_TO_COVERAGE and depth testing

(Asked by: username_0 on 2019-01-31)

I am currently looking into alternatives to my current, somewhat slow but exact, OIT approach. Specifically, GL\_SAMPLE\_ALPHA\_TO\_COVERAGE to convert the alpha value into a per-sample mask.

```
// draw opaque objects
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
glEnable(GL_SAMPLE_ALPHA_TO_ONE);
glDisable(GL_CULL_FACE);
// draw translucent objects

```

However, if multiple alpha-blended faces are behind one another (such as the back faces which I would want to be visible) I am only seeing the front most one. Is depth testing not done per sample? Can I force it to be done per sample? According to <https://www.khronos.org/opengl/wiki/Depth_Test> it should already be per sample.

Multisampling is enabled and works fine for everything else (my OIT shaders in fact do sorting per sample which might be a reason for the slowness). The FBO being drawn into is provided by Qt.

**Tags:** opengl, blending

> **Comments:**
> **username_1**: Not sure exactly what you are doing, but do the surfaces have the same alpha value? That *might* generate the same coverage mask for two surfaces and, hence, only the closer one would be seen.  
> **username_0**: @username_1 good idea! yes that is in fact the case, especially with the back faces.  
> **username_0**: @username_1 After creating my own randomized alpha to coverage shader (writing gl_SampleMask[0]) I can confirm that this solves the issue.  
> **username_1**: No worries - I had suspicions as, in the past, I once was trying to propose better hardware for "screen door" translucency to address this sort of thing.  

---

## 1 answers

### Answer by username_1 on 2019-01-31. Score: 1 | Accepted answer

(Promoting comment to answer)
Do the faces have the same alpha value? That might generate the same coverage mask for the surfaces and, hence, only the closest one would be seen.


---

