         vec2 outputDim = viewport_.zw - vec2(2 * borderWidth_);
 
         if (any(greaterThan(abs(centeredPos), outputDim * 0.5))) {
-            borderValue = 1.0;
+            border = true;
         }
         // adjust texture coords
         // rescaling to size without border around the center


#if !defined(BLENDMODE_REPLACE)
    // if a blend mode other than "replace" is used, discard output for transparent fragments
    if (srcColor.a == 0.0) {
	    discard;
    }
#endif

    FragData0 = mix(srcColor, borderColor_, borderValue);

#ifdef ADDITIONAL_COLOR_LAYERS
    ADDITIONAL_COLOR_LAYER_WRITE
#endif

    PickingData = mix(texture(picking_, texCoord), vec4(0.0), borderValue);
    gl_FragDepth = mix(texture(depth_, texCoord).r, 1.0, borderValue);
}


    bool isBorder = false;
    // The BorderValue is used as a step function for determining the output results by mix.
    // If set to false, the textures will be sampled, otherwise the border color is set.
    bool border = false; 

    if (borderWidth_ > 0) {
        // set border flag iff the fragment coord is within the border
