I have written a small C++ program to generate bezier surface using 4x4 control points.
What I want to do next is to parallelize this process and break the whole surface into sub-patches where each thread will only generate coordinates based on a boundary(bbox) assigned to it.
sample code:
for(i=0;i<steps;i++)
{
float u = i/(steps-1);
for(j=0;j<steps;j++)
{
float v = j/(steps-1);
Point P = calculate_bezier(u,v);
}
}
calculate_bezier is a function that returns a point on the surface based on the control points. Variable "steps" decides how fine the surface is tesslated.
Here's a not-so-good picture showing what I want to acheive:
Each color represents a small bounding box assigned to a thread, which then executes the above snippet of code and generates bezier points in respective areas. I know min/max of these bboxes.
I wanted to ask HOW to do it. I mean, how to restrict the bezier-coordinate generation process only to a bounding box area? Given the bbox bounds for each thread, how will this affect the u and v values?