Observation of patch-drawing dependency through OpenGL shaders

31 views
Skip to first unread message

Bruce M

unread,
Oct 5, 2021, 10:20:56 AM10/5/21
to OpenSubdiv Forum
Hello,

I just want to make sure an observation that surprised me is correct.

Given a patch array of regular type (uniform bicubic b-spline basis)--and a small topology consisting of boundaries or creases--this line works perfectly for me:

glDrawElements(GL_PATCHES, 60 * 16, GL_UNSIGNED_INT, reinterpret_cast<void*>(0u));

However, if I change the starting index by a one-patch offset, like this:
GLuint startOffset = 16u * sizeof(GLuint);
glDrawElements(GL_PATCHES, 59 * 16, GL_UNSIGNED_INT, reinterpret_cast<void*>(startOffset));

then numerous patches draw incorrectly--almost correct but with large gaps. (If my topology contains no boundaries or creases, they seem to draw correctly.)

Gaps.png

My observation, then, is that in general, the calculation for drawing some patches may depend upon previous patches in the patch array having been drawn. Is this observation correct?

I am aware that OpenSubdiv offers the ability to create patch tables for select coarse faces. It has been a very useful library.

Thanks
Bruce

Bruce M

unread,
Oct 6, 2021, 10:46:52 AM10/6/21
to OpenSubdiv Forum
Update: My observation is incorrect.

My issue was not updating the uniform "PrimitiveIdBase" which corresponds to the first element drawn by the call to glDrawElements.

David G Yu

unread,
Oct 6, 2021, 8:53:04 PM10/6/21
to OpenSubdiv Forum
That's right, there are additional data buffers containing PatchParam data (and potentially face-varying PatchParam data) needed to correctly evaluate or draw the patches. Using PrimitiveIdBase will help in case like yours where you want to offset into the buffers, but in the more general case if you want to draw an arbitrary subset of patches, then you'll need to make sure to take care of accessing the correct corresponding PatchParam for each patch that you intend to evaluate or draw.

-David

Reply all
Reply to author
Forward
0 new messages