Sailing Ship Test
In the Fall of 2021, I took at class at UCF called CAP4720: Computer Graphics with professor Sumanta Pattanaik. I'd been really interested in working on lower-level graphics programming work, as I got a small taste of it from both my time at Universal Creative and from a favorite programming channel of mine on YouTube - Sebastian Lague. But this class finally gave me the excuse to dedicate time to the craft, as well as the resources and structure I needed to get started.
Our first set of assignments were pretty basic, just going through the process of how one gets vertex data loaded into a vertex buffer, preparing models for rendering, and creating simple vertex and fragment shaders to position models and eventually cameras in a world space. But the class was moving a bit slow for me - the assignments were nice, short things I could do each week to reinforce what I'd learned the last. But I wanted to play around a bit more.
So I made this:
This little demo is very simple and straightforward - there's a pirate ship heaving, rolling, and pitching in the ocean's waves on an empty blue world. The ship was a quick little asset I made in Blender, as always, and very clearly not textured.
The ocean was the interesting part, really. The waves are generated using Perlin Noise, a mathematical function to generate somewhat realistic-looking patterns that was originally created for use with the original Tron film, back in 1982. It's been used ever since for procedural generation of patterns, textures, worlds, and more.
Here, I sample Perlin noise twice for each vertex in the ocean's mesh (in the vertex shader program), multiplying it by different values each time. These results are combined together to get the vertical displacement of that vertex, resulting in an ocean that has somewhat natural looking turbulence. In addition, this sample is actually offset by the time since the program has started running, resulting in the waves naturally moving opposite the pirate ship's direction of travel.
Of course, this little demo had limitations. Nothing in here is actually moving in a world space - it's "faked," and that's totally okay. This isn't truly an interactive little demo (though you can configure all the variables used for this by clicking on the "Observable" icon in the bottom right of the demo, or by clicking this link), and is more like a little display of rendering technology. Another big issue I had was that we were learning lighting at the time - how to properly shade and simulate diffuse, specular, and ambient lighting. And my ocean simply didn't support that. As the vertex data was manipulated in the vertex shader, and I didn't manipulate the normals in any way, I couldn't rely on them for lighting.
Both of those problems would be fixed at the end of the semester, in the final project for the course, where a classmate and I transformed this little tech demo into a fully-fledged game...