I’ve decided to document my journey during the most pivot part of my university life, final year. Third year. Big year. This year accounts for 75% of the mark I’ll get when I graduate. Last year accounts for 25% and, considering it was a turbulent year to say the least, I still did rather well. Getting a 75% which is a 1st (the highest possible grade) however, it’s down from the 85% I got for first year. Naturally the grade might drop a bit since it’s a more advanced year, but working 3-4 days a week as well as various other issues got in the way. The grade, while still a first, is too close for my comfort. Hence, this year I’m dedicating all my time to studies. I’m determined to get >70% and to get my first. Here I’ll be covering what I’ve been working on and what’s coming next.
By far the most interesting piece of coursework I’ve been working on is for the computer graphics algorithms module, last week I spent the weekend collecting subject to study with a technique called photogrammetry. Chances are, if you’re like me, you might have heard of the term when talking about video games. The technique has been used extensively in big budget video games such as Star Wars: Battlefront. Photographs are taken around a subject, which are then ran through an algorithm which will connect the photographs together. Detecting the crossover between them and, using the focal length of a camera’s lens, the algorithm produces a 3D model of the subject. It’s a lengthy process but with the right subject and technique, can produce amazing results.
My initial experiments were using my old GTX 970, I figured the unique features on the subject would make producing a model easy. This would be semi-true. However, my technique was all wrong, with minimal crossover and poor lighting conditions. As a result the generated model was a total disaster, with sides totally misconnected and a large portion of the subject floating in nothingness plus. Additionally, some of the ground was also replicated, though this is something we can expect and can be removed software such as Blender. Next attempt was a glossy metal bottle, which was slightly better but the lack of features and poor technique produced one good size but the back of the model completely exploded and the top and bottom were missing.
However with those experiences I learnt and changed my technique. Introducing a turntable in the form of a set of draws I had that so happen to be on a pivot. I took my photographs facing the natural light outside. Using a turntable instead of manually rotating my subject, I was able to get a lot of crossover without the subject moving position. Additionally, I manually edited the photos by cropping them and blurring the background – so the algorithm wouldn’t find features in it. Next I found a small subject with a lot of features, a rock from outside my apartment. The result from all of this was the 3D model you see above. A, in my opinion, fantastic 3D model that’s near photo realistic. It’d need to be optimized before it could be used in a game, however, as it contains over 1,200,000 vertices. Though the texture might be somewhat limited by my phone camera’s limited resolution. The result is still fantastic! Next I’m looking forward to creating a graphics engine in OpenGL to display it.
Programming Language Principles
Video Game Vibes
Finally, I started the year working on a game using the Phaser 3 framework. This was for my Internet Game Design module, but I took a break from it to focus on other coursework. Now that I’ve returned to it, I’ve started rewriting it from scratch. I found myself having to work around Phaser with my old approach while I wanted to have absolute control over my game’s engine. Despite starting out using the standard HTML5 Canvas 2D, I switched over to WebGL as there are certain visual effects I want to achieve that can only be achieved with the shader capabilities that WebGL provides.
Though one of the most unexpected challenges was ensuring consistent frame-pacing with my own engine, initially frame-pacing was consistently over the 16.6ms timeframe of a 60fps game. Resulting in visible and distracting judder, however by using RequestAnimationFrame function, which relies on the browser to request a frame, I was able to mostly solve the problem. Finally another issue with frame-pacing was the frame request function would start the calculations and rendering of a frame which would be inconsistent. Hence I switched to a double-buffer solution by having the game render to an invisible canvas then copying the contents of the canvas to the visible canvas at the start of the request. Though this approach will introduce 1 frame (16.66ms) of lag, it should ensure great frame-persistence, however I’m not in full control of the game playing environment and the browser could introduce problems in unforeseen ways. You can find the original, Phaser 3, approach here and my custom WebGL version here.
There’s one topic rather conspicuous by its absence, my individual project which replaces the traditional dissertation. That’s because I’m focusing on lecture-based module coursework during term-time and will dedicate the entire Winter break towards my project. Which is a neural network image upscaler, though I recently submitted my interim report detailing my research so far. I’m looking forward to the coursework ahead, I need to 3D print my rock and write a report about my OpenGL application, finish developing my game and finally round off my programming languages coursework by 13th December 2019.