Sign in to follow this  
theZapper

Drawing a curve with a pixel shader

Recommended Posts

theZapper    150
I'm trying to work out how to get a pixel shader to draw a Quadratic Bezier curve based on the vertices of the current triangle it's rasterizing. I'm stuck in a number of places. 1) The Quadratic curve equation is based around the idea that at any point along the given curve, It can work out the x,y co-ordinates of that point. However, in a pixel shader I don't know how far along the curve the current pixel is, or even if it's on the curve. I somehow need to use this equation or some variation to return a true/false for if it's above or below, and preferably a distance to the curve. 2) I'm not quite sure how to transmit the positions of the surrounding three triangle verts to the pixel shader. It will probably need these to calculate the curve. If anyone knows of any decent articles that might explain some of these areas I'd appreciate it. Or even better how to do it! Cheers

Share this post


Link to post
Share on other sites
chairthrower    440

maybe this link would be useful,

I was looking in the past (and some more) at various solutions for efficient hardware-aided curve rasterization methods. Those ideas mostly focused on using the graphical hardware for accelerating the geometry generation process. But what happens, when we completely skip the geometry generation step? Even more blazing performance and totally resolution-independent rendering.

Smart curve rasterization is the first step towards efficient drawing API implementation. By combining the solution with additional dynamical GPU-programmable pipeline elements (gradients, triangulation, anti-aliasing, multi-sample rendering) we can achieve blazing-fast vector-based drawing tool.

www.mdk.org.pl/2007/10/27/curvy-blues

from memory there are some shader examples given for quadratic beziers,

also,
http://www.mdk.org.pl/2007/8/16/vector-drawing-opengl-polygon-tessellation
http://www.mdk.org.pl/articles/2007/08/06/vector-drawing-opengl-shaders-and-cairo

the site seems down at the moment (for me) but the first link works with google cache


also here - but its more theoretical and supposedly slightly misleading as to exact details,
note the ip rights are already claimed
http://research.microsoft.com/~cloop/loopblinn05.pdf

Share this post


Link to post
Share on other sites
theZapper    150
Thanks

I'll check those links out.

The reason I'm looking at this is because I stumbled upon the Microsoft research paper you mentioned and read through it. It seems pretty good but in true research paper style they assume you're already a genius in the area, so some of the maths is a bit over my head.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this