diff --git a/src/GafferUI/StandardStyle.cpp b/src/GafferUI/StandardStyle.cpp index a386de4ec8d..b05cccf6d73 100644 --- a/src/GafferUI/StandardStyle.cpp +++ b/src/GafferUI/StandardStyle.cpp @@ -581,8 +581,6 @@ void StandardStyle::bind( const Style *currentStyle ) const return; } - glEnable( GL_BLEND ); - glBlendFuncSeparate( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); glUseProgram( shader()->program() ); if( IECoreGL::Selector *selector = IECoreGL::Selector::currentSelector() ) @@ -592,6 +590,13 @@ void StandardStyle::bind( const Style *currentStyle ) const selector->pushIDShader( shader() ); } } + else + { + // Enable blending only for non-selection renders as it can + // corrupt the selection buffer on some graphics hardware. + glEnable( GL_BLEND ); + glBlendFuncSeparate( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); + } } Imath::Box3f StandardStyle::characterBound( TextType textType ) const @@ -1129,8 +1134,6 @@ void StandardStyle::renderImage( const Imath::Box2f &box, const IECoreGL::Textur { glPushAttrib( GL_COLOR_BUFFER_BIT ); - // As the image is already pre-multiplied we need to change our blend mode. - glEnable( GL_BLEND ); if( !IECoreGL::Selector::currentSelector() ) { // Some users have reported crashes that were traced back to this call @@ -1139,6 +1142,9 @@ void StandardStyle::renderImage( const Imath::Box2f &box, const IECoreGL::Textur // didn't correspond to actual gadgets. // Don't change it when rendering the selection pass since // blending should not be applied to an integer buffer anyways. + + // As the image is already pre-multiplied we need to change our blend mode. + glEnable( GL_BLEND ); glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); } diff --git a/src/GafferUI/ViewportGadget.cpp b/src/GafferUI/ViewportGadget.cpp index 43471d67acb..a05e3314680 100644 --- a/src/GafferUI/ViewportGadget.cpp +++ b/src/GafferUI/ViewportGadget.cpp @@ -1288,7 +1288,9 @@ void ViewportGadget::renderInternal( RenderReason reason, Gadget::Layer filterLa if( reason != RenderReason::Draw ) { // We're doing selection so post-processing doesn't matter. Just - // render direct to output buffer. + // render direct to output buffer without blending as that can + // corrupt the selection buffer on some graphics hardware. + glDisable( GL_BLEND ); renderLayerInternal( reason, layer, viewTransform, bound, selector ); continue; }