1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Simon F Jan 31 at 11:55
  • 1
    $\begingroup$ @SimonF good idea! yes that is in fact the case, especially with the back faces. $\endgroup$ – Joe Jan 31 at 12:04
  • 1
    $\begingroup$ @SimonF After creating my own randomized alpha to coverage shader (writing gl_SampleMask[0]) I can confirm that this solves the issue. $\endgroup$ – Joe Jan 31 at 12:51
  • $\begingroup$ 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. $\endgroup$ – Simon F Jan 31 at 12:55
1
$\begingroup$

(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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.