title: Drawing inner shadow for Bezier curves in OpenGL / GLSL
body: <p>I'm trying to draw an inner glow/shadow for an object consisting of four cubic Bezier curves. To draw a single Bezier curve I'm splitting it into segments and then calculating distances from current pixel to each line segment and finally I'm blending it with <code>min</code>:</p>
  
  <p><code>// No GL_MAX blending mode in OpenGL ES 2.0
  d_min = min(d_min, d)
  </code></p>
  
  <p>where <code>d</code> is a distance for every segment. Zoomed in example of blending two line segments:</p>
  
  <p><a href="https://i.stack.imgur.com/ShKBD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ShKBD.png" alt="enter image description here"></a></p>
  
  <p>It works reasonably well when you have ~25 segments representing a short Bezier curve</p>
  
  <p><a href="https://i.stack.imgur.com/5bpp6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5bpp6.png" alt="enter image description here"></a></p>
  
  <p>except for "gutters" in the places where Bezier curves and their respective gradients combine.</p>
  
  <p><strong>Q:</strong> How can I avoid these artifacts? Is there a better method for drawing inner glow/shadow?</p>
  
  <p><a href="https://i.stack.imgur.com/mPezH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mPezH.png" alt="enter image description here"></a></p>