We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › calculating curves in the gpu
Page Index Toggle Pages: 1
calculating curves in the gpu? (Read 2155 times)
calculating curves in the gpu?
May 9th, 2010, 2:59am
 
I was wondering if its possible to calculate curves in the gpu? I was using the library glgraphic that has a class called glmodel that allow to calculate vertex point in the gpu, you can draw point and lines in a very effective way, you can have thouthants of lines or points that run very fast, i was wondering if theres something like this but for making curves instead of points or lines.

any idea?

thanks
Re: calculating curves in the gpu?
Reply #1 - May 9th, 2010, 7:24am
 
As far as I understand, a curve is nothing but an array of lines that give the appearance of curve.  So, I guess the question is if you need the curve to be dynamic (changing every frame), or if it's a static curve (used for multiple frames).  If it's a static curve, then you could calculate the curve vertexes on the CPU (Toxi's library does a good job of this in the Spline Classes), then stick them into a Display List, Vertex Buffer, or VBO to render them fast on the GPU.  If your looking for something dynamic, I don't know enough to answer that, but it would likely be done using a GLSL Shader.
Re: calculating curves in the gpu?
Reply #2 - May 9th, 2010, 8:15am
 
one way would be to use geometry shader with tesselation, creating new vertices for detail along the curve

other way could be passing a list of points to the vertex shader (list of points you want on your curve) and on the shader compute the correct curve point positions.

this might work but would need some special way to send data to the gpu. i believe the geoemtry shader way would be the best.
Re: calculating curves in the gpu?
Reply #3 - May 9th, 2010, 4:12pm
 
one question, why do you say if they are static i should use vbos or vertex buffer? are those cant be dynamic?

thanks
Re: calculating curves in the gpu?
Reply #4 - May 10th, 2010, 7:23am
 
he means if you have static (one-time calculated curves) that you can compute it on the cpu and upload to videocard memory (vbo, displaylist, va) and just use the power to render them.
Re: calculating curves in the gpu?
Reply #5 - May 10th, 2010, 10:02am
 
Hi, i have prepared an example on how to evaluate a bezier curve with a geometry shader.

Pass a line (both points are used as the anchor points) and on texcoord 0 and 1 pass the controlpoints.
Click on the points to move them

http://victamin.googlecode.com/files/GPUBezier.zip

more info: http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Examination_of_cases

Have fun.
Page Index Toggle Pages: 1