Skip to content

Commit

Permalink
StandardStyle : Discard fragments with zero texture alpha
Browse files Browse the repository at this point in the history
We were already trying to discard fragments with zero alpha so that they don't affect selection hits. But we were doing that before taking the texture alpha into account. Although the original motivation was selection hits, discarding zero alpha also avoids depth buffer writes, which is important now that Backdrops use depth buffering to control the order of nesting.
  • Loading branch information
johnhaddon committed Jan 2, 2024
1 parent 2b109cb commit d42c572
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/GafferUI/StandardStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,11 +1499,6 @@ static const std::string &fragmentSource()
" OUTCOLOR.a *= ieFilteredPulse( 0.2, 0.8, gl_TexCoord[0].x );"
" }"

" if( OUTCOLOR.a == 0.0 )"
" {"
" discard;"
" }"

/// \todo Deal with all colourspace nonsense outside of the shader. Ideally the shader would accept only linear"
/// textures and output only linear data."

Expand All @@ -1524,6 +1519,11 @@ static const std::string &fragmentSource()
" OUTCOLOR = vec4( OUTCOLOR.rgb, OUTCOLOR.a * texture2D( texture, gl_TexCoord[0].xy ).a );"
" }\n"

" if( OUTCOLOR.a == 0.0 )"
" {"
" discard;"
" }\n"

"#if __VERSION__ >= 330\n"
" ieCoreGLNameOut = ieCoreGLNameIn;\n"
"#endif\n"
Expand Down

0 comments on commit d42c572

Please sign in to comment.