Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I found a shader code to draw filled Quadratic Bezier in

http://http.developer.nvidia.com/GPUGems3/gpugems3_ch25.html

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

share|improve this question

1 Answer 1

up vote 3 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.

Changing

float alpha = 0.5 - sd;

to

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

 
discard

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.