Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I found a shader code to draw filled Quadratic Bezier in

How can use something similar to draw a Bezier line that follows the same path?

share|improve this question
up vote 5 down vote accepted

The HLSL code in the linked article gives you a signed distance to the curve, which is used for antialiasing. Since the value is signed instead of clamped, it can be used on both sides of the curve. Absolute value of the signed distance gives the distance to the curve.


float alpha = 0.5 - sd;


float alpha = 1.0 - abs(sd);

gives you alpha = 1 when the pixel is exactly on the curve and alpha between [0,1] when the pixel is within 1 pixel radius of the curve.

You can set the thickness of the curve with:

float alpha = thickness - abs(sd);

Beware that the polygon must be large enough to cover the thick curve.

share|improve this answer
thanks, tested and working :D – Zhen Feb 15 '13 at 9:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.