Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha mask + translucent feature not working #10533

Closed
lilleyse opened this issue Jul 11, 2022 · 0 comments · Fixed by #10549
Closed

Alpha mask + translucent feature not working #10533

lilleyse opened this issue Jul 11, 2022 · 0 comments · Fixed by #10549

Comments

@lilleyse
Copy link
Contributor

lilleyse commented Jul 11, 2022

This is a ModelExperimental bug

Background: When a feature in a primitive become translucent we generate an opaque command and a translucent command. CPUStylingPipelineStage is responsible for rendering only opaque features in the opaque command and only translucent features in the translucent command.

The problem is that renderResources.alphaOptions.alphaMode is set to AlphaMode.BLEND and #define ALPHA_MODE_BLEND is set for both commands.

In ModelExperimentalFS.glsl this means the opaque command actually goes down the ALPHA_MODE_BLEND code path and doesn't discard alpha-mask pixels. Which leads to the artifacts in the gif below.

vec4 handleAlpha(vec3 color, float alpha)
{
    #ifdef ALPHA_MODE_MASK
    if (alpha < u_alphaCutoff) {
        discard;
    }
    return vec4(color, 1.0);
    #elif defined(ALPHA_MODE_BLEND)
    return vec4(color, alpha);
    #else // OPAQUE
    return vec4(color, 1.0);
    #endif
}

Peek 2022-07-11 14-47

Sandcastle

N12E045_D101_S002_T001_L4_U12_R0.glb.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants