Interpolation
By Casey Muratori
I wanted to end the grass series with a little introduction to the concept of interpolation, for those programmers out there who perhaps haven’t been exposed to the basics. I spent a good deal of time trying to type out an article, but it just didn’t work. There’s too much stuff to talk about, even if I leave a lot out, and it’s too hard to emphasize the important parts when I can’t easily point at parts of diagrams.
So, I tried a different approach, and recorded a video of me drawing everything out on my notebook. The first one was ridiculously long, so I recorded a second one that was greatly abridged, and I talked very quickly. It’s an experiment, but in both cases I was able to get a lot more across than I could with text. It’s still a bit long, but you could, you know, um… watch it in parts?
I was trying to keep the video to an hour, so I ran out of time to talk about the second interpolation case in the grass code, which was bitmap interpolation. This is just bilinear interpolation, so I was going to show how bilinear interpolation is just applying the b(t) function three times, and how it boils down to the same weighted sum equation as well. Nothing particularly interesting, but I would have liked to have gone fast enough to get that in there so it could just reinforce the notion that this equation is everywhere.
Similarly, in the abridged version, I didn’t talk about how there are multiple degrees of Bezier curves, and how you can construct other ones (quadratic, etc.) by doing the exact same pyramid method just by adding or removing rows of the pyramid. Hopefully it’s straightforward to see how to do that.
For quick reference, here are the related Wikipedia pages:
• 
Barycentric coordinates, so you can read about how these are used
• 
Bezier curves  —  has some nice animations, unfortunately doesn’t ever draw the pyramids
• 
Bilinear blending  —  like Beziers, it’s built from repeated linear blends
Anyway, despite the fact that I don’t really have a proper set up, I like how the video came out, and I think, with practice, I could do some nice tutorials like this that might be useful to people. I think with more practice I could structure them so that they were less sprawling. Let me know what you think! There are a lot of things I wouldn’t have the time to do properly in article format (unrelated to The Witness, just general programming things) that I could easily do in this format, so if people actually find it useful, I’d try to record some more after Witness Wednesdays wrap up.
And speaking of Witness Wednesdays, now that I’ve finished the series on grass, it is time for a new topic: code. Yes, just code. One of the things I did while working on The Witness was to put a new entity listing panel in the editor, and I think it would make a good case study for how to put a lot of features into something quickly and without a lot of code. So check back next Wednesday, when I’ll start walking through how I went about writing it, and show a lot of examples of how I structured the code so it could be built quickly without becoming excessively janky.
For more information on my current projects, head over to computerenhance.com.