My university runs a 3D game development course once a year. It originally was taught using OpenGL, but my professor had decided to switch the curriculum to focus on using the Vulkan API during the Fall 2018 semester. My class was the first to take the revised version of the course. Professor Kehoe had offered a C based seed project for us to get started with, but I had a lot of issues getting his project to build and run on my machine. After a week of failed attempts, I decided to build my project from the ground up in C++. I followed the vulkan-tutorial site for guidance throughout the semester. I considered my Vulkan project to be as more of an experimental playground for myself. It was a way of trying to learn C++ on my own, so I decided to throw shaders into the mix as well. My primary experience with shaders had been only within Unity prior to this class. Unity combined the fragment and vertex shaders into a single file, so I never had the experience of working with as separate files. My GLSL experience was very limited as well prior to this class, so the experience to finally experiment was exciting to me.
Once the basic template of the project was complete, and was able to support up to two 3D models at any given time, I got to work on the shaders. I started with a plain vertex and fragment shader to ensure that the graphics pipeline was functional. I didn’t do anything special besides applying a RGB gradient across the available surface so it would be immediately obvious. whether the shaders were working properly and going through the pipeline.
Once I was sure that the vertex and fragment shaders were functioning, I got to work on writing a geometry shader. I had never written one and I wanted to push myself out of my comfort zone. A shader module would have to be created for each shader file I planned to use and then prep shader files to be used in the graphics pipeline. I also learned about how strict ordering could be for the shader stages. I initially put the geometry shader at the end of the shaderStages array and found that my geometry shader was not being fed into the pipeline. I had also made the mistake of not increasing the size of the shaderStages array and found my executable crashing as a result.
Once I straightened out my mistakes in the pipeline, I ran into some issues writing the geometry shader. It was a mixture of some GLSL functions not playing nice in Vulkan or simply inexperience with GLSL. I ended up writing a basic geometry shader where it would find the model’s vertices, then draw lines from each vertex to the origin point of the model. I utilized a dog model (made by my professor) as the testing dummy . The house model was only being used to verify that the entity system as capable of supporting multiple entities. In my opinion, it was pretty fun watching the model get reduced into
spaghetti.
I included user input options to allow the user to move the model around and distort it. The user had the ability to alter the rotation angle, zoom in/out, and stretch the model along the x, y, and z axes. I had also included a sound manager to play background music (mostly for my own entertainment).
I had difficulties pushing to my initial GitHub repository due to some mistakes I made with my .gitignore file, so I had to push the final solution to a new repository. Although this was a minor issue, the repository containing the final changes to the project does not reflect the progress and changes between commits. The final result was not impressive whatsoever, but this class project inspired me to spend my free time learning GLSL. I really hope to revisit Vulkan once I have a better understanding of GLSL.