简体   繁体   中英

GL_Triangles with Tessellation Shaders

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?

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 (eg GL_POINTS ).

Update:

Assuming you are discussing a Bézier surface , then the control points can be visualized thus:

贝塞尔曲面

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM