Reputation: 25094
When i am using Tessellation Shaders, do I have to pass from my CPU Program Patches rather then Triangles?.
glDrawArrays(GL_PATCHES, 0, 3); //Works with Tess Shaders
glDrawArrays(GL_TRIANGLES, 0, 3); //Works not with Tess Shaders
What is a Patch exactly to visualize it? Can it be a triangle which is being subdivided?
Upvotes: 3
Views: 1842
Reputation: 43319
A patch is just a collection of points with no real intrinsic structure... your TCS and TES are what make sense out of them. Unlike GL_TRIANGLES
(which is strictly defined by 3 vertices), GL_PATCHES
has no pre-defined number of vertices per-patch. You set the number of vertices in a patch yourself with:
glPatchParameteri (GL_PATCH_VERTICES, N);
// where N is some value less than GL_MAX_PATCH_VERTICES
Then, every N
-many vertices drawn defines a new patch primitive.
Patches are really just a collection of control points for the evaluation of a surface. This is literally why there is an optional stage called Tessellation Control Shader
that feeds data to a Tessellation Evaluation Shader
. Without more details about the type of surface you are evaluating, about the only way to visualize them is as a point cloud (e.g. GL_POINTS
).
The red points are the control points (vertices in GL_PATCHES
), the blue lines are artifical (just for the sake of visualization) and the black squares are the evaluated surface (result of a Tessellation Evaluation Shader). If you tried to visualize this before tessellation evaluation, then your patch would be nothing but red dots and you would have a heck of a time trying to make sense of them.
Upvotes: 8