# Patches with more control points? (biquadratic, bicubic, etc)

The book mentions this briefly in chapter 11:

A patch consists of a certain number of control points, generally:

• bilinear: Four control points, one at each corner
• bicubic: Sixteen control points

And a few paragraphs later:

Because the mathematics of curved surfaces is quite involved, you’ll only be working with four control points per patch in this chapter.

Does anyone know where I can find documentation on how to do use those higher numbers of control points? At the least I think I need to know their memory layout order in the control point buffer. I’ve been searching the Metal docs for hours and I don’t see anything.

I’m working on a 2D app, and I want to create lots of cubic bezier shapes (and other similar curves, like splines). I wanted to experiment with `drawPatches` to see if it would help. My patch would only be bent “sideways” in 2D, if that’s possible, and not taking advantage of 3D surface curvature, yet, but this way still might be faster than creating the bezier subdivisions in CPU code.

1 Like

One of my go-to books is an older, small and expensive volume called 3D Graphics for Game Programming by JungHyun Han. He has a chapter on Parametric Curves and Surfaces.

Here’s the website for the book: Books · media lab. If you scroll down, there are lecture notes in PowerPoint format which contain the gist of the book.

Lecture note 6 is the one for Parametric Curves and Surfaces that discusses various curves and patches:
http://media.korea.ac.kr/books/notes/1/chapter6.ppt

If you’re googling, “Parametric Curves and Surfaces” is what you’re looking for - there are a number of resources out there. DirectX is very similar to Metal.

This is a really old playground, but it still works!, that I created when I was playing around with tessellation. I never got the K3DSurf section to work fully in all the domains, but it was fun. It has examples of biquadratic and bicubic patches.

ParametricFun.playground.zip (118.6 KB)

P.S. If you’re a \$99 member of ACM, you have access to O’Reilly’s books, and 3D Graphics for Game Programming is available in there.

2 Likes

Cool, thank you! I just tried your “Biquadratic Quad Patch” Playground. After commenting out a few lines in the shader that were overwriting the `uv` vector, I see a curved surface. I’ll be chewing on this for a while.

I was wondering how the heck Apple could create an API this sophisticated, and have incomplete docs for it (for the control point order I mean), and yet somehow people are able to use it. So this must be the answer – that certain things are standard, or copied over from OpenGL. Either that I’m just getting into deep corners that are only used by a few game engine developers, who themselves burn a lot of DTS tickets or talk directly to Metal developers.

That book appears to use OpenGL so I wouldn’t have thought to read it to help me with Metal, but I will be going through the slides. It looks really good.

I’m not an expert in this area, but I think once you understand how Metal tessellation works, and there’s not a lot to it, then it’s just math. The math applies to all APIs. I’ve found that DirectX is very similar to Metal, so when I’m trying to solve a problem I look for DirectX examples rather than OpenGL.

That book does use OpenGL, but I like it for the explanations rather than the code, and I think you get all that from the slides.

I do mostly agree with out you about the Apple docs - they tend to put out something either really simple that doesn’t get you very far, or something mind-blowingly brilliantly complicated like the rendering terrain sample: Apple Developer Documentation which takes me six months to digest.

The only Apple ticket I’ve ever used was for tessellation