Static Rectangle, now with more progress!
The following is progress made over a few weeks, a few weeks ago. I was still wrapping my head around how Vulkan works, and really just trying to get stuff to work. It was one step forward, two steps back for a time, that’s just how it is sometimes.
Jumping off from where I was at the end of the last post, I implemented a camera controller which at this time handled all user input. I spent a fair whack of time coming up with a way to handle what happened when the mouse goes outside the bounds of the window, I was quite proud of that. I later found out that GLFW (the cross-platform window framework I am using) has an option to do this for you, you just have to turn it on (and know it exists).
From there, I moved on to lighting. I implemented simple directional lighting fairly quickly, so I moved on to point lights. This is when I broke everything and it took me an embarrassingly long time to figure out what happened… as it turned out, nothing had happened my ground plane just had inverted normals. Nothing in my renderer at this point helps me figure this stuff out, so I’ll definitely be adding debug drawing methods in the future, it’s a bit of a chicken/egg situation at this point in development.

I was getting a bit tired of looking at cubes and spheres. So, next up was implementing OBJ loading and my first pass at structuring a model class. For file loading, it was a toss up between tinyobjloader and assimp. I went with tinyobjloader for now, primarily because it’s a very lightweight header only implementation. Assimp is super full featured which I may look into in the future. Doing this, I learnt a bit about the OBJ format I wasn’t aware of, which is funny because I have used it in some form or another for 15+ years. I actually may look into my own format at some point, it could be fun and a great learning experience to write my own exporter for Maya and my own parser for Static Rectangle.
In the above clip, I had also implemented blinn-phong shading. That was surprisingly simple and I’m quite excited to see what I can do with shaders in the future.
Next, I needed to do some refactoring. The input was still in the camera controller, so I needed to move it out. I wasn’t entirely sure what I wanted, so I moved it to the window, as that is where the callbacks are registered. However, it felt weird needing access to the window to get input, so I moved it into its own class which did present some issues with GLFW that needed some… creative solutions. In the end, I’m pretty happy with where it is, it’s by no means complete, it’s still very basic but it works.
If you need access to the keyboard or mouse you do so from an application owned instance of the input by doing something like input.keyboard.keys[keycode].isDown
or input.mouse.position.x
etc.
I also dug out some old models from yesteryear, I was curious to see how it handled models which weren’t optimised at all. Turns out, fine.

I wanted to look at something that wasn’t a solid colour, but I had yet to get textures working (I had attempted to a number of times at this point). So instead, I added vertex colours to an old model of mine. This was actually easier said than done, as this is where I found out that OBJ technically doesn’t support vertex colours. There are a couple of unofficial extensions, and one of those is supported by tinyobjloader, so I hacked them in using a script I wrote for Maya.
And that pretty much takes us to where I am today, this last screen recording was from a couple of weeks ago. I’m currently making my way through the Vulkan Cookbook by Pawel Lapinski and I’ve already made some changes and flagged a few TODOs as a result.
I did get textures working today, but I’ll save that for another post!
0 Comments