   float right=Warp(vec2(0, posNorm.y)).x+0.999;
   float top=Warp(vec2(posNorm.x,1)).y-1;
   float bottom=Warp(vec2(posNorm.x,0)).y+0.999;
-  if(posNorm.x < left || posNorm.x >= right 
-    || posNorm.y < top || posNorm.y >= bottom){
-    FragColor = vec4(0.0,0,0,1.0);
-  }
+  float alpha=max(max(
+	smoothstep(-CURVATURE_SMOOTH,0,left-posNorm.x),
+	smoothstep(0,CURVATURE_SMOOTH,posNorm.x-right)
+  ),max(
+	smoothstep(-CURVATURE_SMOOTH,0,top-posNorm.y),
+	smoothstep(0,CURVATURE_SMOOTH,posNorm.y-bottom)
+  ));
+  res=mix(res,vec4(0,0,0,1),alpha);
+  FragColor=res;
 #else
   if(v_texCoord.x <= 0 || v_texCoord.x >= (rubyInputSize.x/rubyTextureSize.x)
     || v_texCoord.y <= 0 || v_texCoord.y >= (rubyInputSize.y/rubyTextureSize.y)){

#define OutSize vec4(rubyOutputSize, 1.0 / rubyOutputSize)

#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float SCANLINE_BASE_BRIGHTNESS;
uniform COMPAT_PRECISION float SCANLINE_SINE_COMP_A;
uniform COMPAT_PRECISION float SCANLINE_SINE_COMP_B;
uniform COMPAT_PRECISION float warpX;
uniform COMPAT_PRECISION float warpY;
uniform COMPAT_PRECISION float maskDark;
uniform COMPAT_PRECISION float maskLight;
uniform COMPAT_PRECISION float shadowMask;
uniform COMPAT_PRECISION float crt_gamma;
uniform COMPAT_PRECISION float monitor_gamma;
#else
#define SCANLINE_BASE_BRIGHTNESS 1
#define SCANLINE_SINE_COMP_A 0.0
#define SCANLINE_SINE_COMP_B 0.40
#define warpX 0.031
#define warpY 0.041
#define maskDark 0.5
#define maskLight 1.5
#define shadowMask 1.0
#define crt_gamma 2.5
#define monitor_gamma 2.2
#endif

/*

/////  comment these lines to disable effects and gain speed  //////
////////////////////////////////////////////////////////////////////

#define CURVATURE // applies barrel distortion to the screen
#define OVERSCAN_X 0.1
#define OVERSCAN_Y 0.1
#define CURVATURE_SMOOTH 0.001

////////////////////////////////////////////////////////////////////
//////////////////////////  END SETTINGS  //////////////////////////
