Our blind charge into the world of 3D graphics continues! This session we grapple with the classic game developer’s rite of passage: staring for two hours at a sea of magenta, trying to get a square with gradient colors to draw on top of it. Both of us proceed to badly misremember the lessons of past graphics classes and projects. OpenGL’s brutal ergonomics offer no extra assistance; we arrive, as many before us have, at the conclusion that the API is bad. But eventually, we stumble into success.
- We got stuck on shader compile errors for a while, not realizing that WebGL 2.0 uses a different GLSL version to the one we observed in the tutorials. One of the pitfalls of learning programming, especially graphics programming, is the subtle disagreement between the version of the thing you’re using and the version the instructions are using.
- We spent some time theorizing why stuff behind the camera doesn’t get rendered, even when the primitives are being sent to the drawing API. Part of the story is backface culling (https://en.wikipedia.org/wiki/Back-face_culling), but the more important thing is something we didn’t discuss: clipping to the visible volume. See https://en.wikipedia.org/wiki/Clip_coordinates for a quick summary.
- Dom asked, what is the “w” coordinate, and why are we using 4D vectors? This is a pretty complex topic, but here’s Wikipedia’s crack at an explanation: https://en.wikipedia.org/wiki/Homogeneous_coordinates#Use_in_computer_graphics_and_computer_vision
- The curious etymology for the word “ampersand”: https://en.wikipedia.org/wiki/Ampersand#Etymology
- “In the long run, we are all dead”, a phrase attributed to economist John Maynard Keynes: https://en.wikiquote.org/wiki/John_Maynard_Keynes
- Triangle fans vs triangle strips: https://stackoverflow.com/questions/20394727/gl-triangle-strip-vs-gl-triangle-fan