Harold Serrano

View Original

How long does it take to develop a game engine?

I've been getting several emails in the last couple of months from indie developers and college students interested in developing a game engine. The bulk of these emails revolves around the question: "How long does it take to develop a game engine"?

I don't know how long it will take you, but I can tell you how long it took me to go from a blank file to this:

In the beginning

When I decided to develop a 3D game engine, I knew next to nothing about C++, Design Patterns, and algorithms. I knew C programming, but I didn't feel comfortable since most of what I knew about programming was self-taught. My bachelor was in Bio-Engineering, not Computer Science. Thus, you can safely assume that my programming skills were borderline basic.

I also knew nothing about OpenGL, Shaders and Computer Graphics.

Developing a game engine required that I mastered all these concepts: C++, Design Patterns, OpenGL, Computer Graphics and Linear Algebra. So, for the first seven to eight months (Feb 2013-Aug-2013), I decided to dwell deep into these concepts. I read a lot. I spent my hours before heading to work, after work and weekends, just studying, reading and learning as much as I could.

My first attempt

It was around Aug-2013 that I started coding the game engine. Around this time I was not wholly knowledgeable about C++, OpenGL nor Linear Algebra but I decided to start coding the engine nonetheless. Unfortunately, the engine's architecture was a total mess, and by Nov 2013, I had to start all over again.

It was not until a year later (Feb-2014) that I succeeded in rendering the first 3D character on the screen.

A lot of work with nothing to show

The year 2014 was depressing. I was spending all of my free time working on the engine. I kept reading and reading about OpenGL and Computer Graphics. However, most of what I implemented would fail. I must say that it was also a year I learned a lot.

From Feb 2014 to May 2014, I worked on the Rendering Engine and added support for 3D model rendering, textures, normal maps, and multi-image. From May 2014 to July 2014, I implemented a crude Digital Asset Imported. That is, I was able to export a 3D model from "Blender" and import it into the engine.

The rest of 2014 was spent on implementing a scenegraph, fine-tuning the Digital Asset Imported, adding support for 3D animations, and learning how to use Blender 3D.

Testing a walking animation in the engine. 

You may not know this yet, but you will need to wear your artistic hat if you want to develop a game engine. It is crucial that you learn how to model 3D characters using tools such as Blender and the workflow used by 3D artists. If you do not take time to learn this, you will not be able to import the correct data into the engine from Blender.

Finally, something to show

It was not until April 2015 that the Rendering Engine showed signs that it was working. On April, I was able to complete Beta version v0.0.1 of the engine.

Version v0.0.1 The game engine is capable of rendering 3D models with textures/normal maps, animation, skyboxes, fonts, sprites and contains a digital asset importer.

The engine had support for 3D models, normal maps, buttons, joystick, shadows and 3D animations. However, most of what I had implemented was crude. Remember, I was learning and failing hard along the way.

The complicated part of an engine

On April 2015, I started working on the Physics Engine. The physics engine, along with the Collision Detection System, is the hardest part of a game engine. Trust me.

The year 2015, was also the year when my temptations to quit development was the strongest. I can't even explain how terrible it is to work on a Collision Detection System. I would work until 2 am almost every day, and every time, that damn Collision System would fail. It was not until October that I finally was able to get the engine to detect collision among convex objects. However, there was a problem with collision tunneling. Essentially, colliding objects would penetrate each other. Unbeknown to me, it was going to take me over a year and three months to get the collision system working.

I Finally Did it

It was not until July 21, 2016, around 2 am, that I succeeded in developing the basic framework of the game engine. Trust me, when I saw the engine working, I screamed, I jumped, and I started dancing Salsa (I'm Latino. Salsa music is in my blood).

It took me a little bit more than three years to develop the basic structure of the game engine. And I have to emphasize the word "basic.". The engine had a basic structure, but it was not ready for prime-time. There was a lot more work to do.

The First Demo

I knew the engine needed a lot more functionality. However, I couldn't wait to develop a simple demo. So, a month later, I developed the demo shown below:

Development started to pick up

After the first demo, development started to go by faster. By October 2016, I had improved the collision detection and fixed issues with 3D animations.

In this beta version v0.0.3 of the engine, animations and collision detection can work simultaneously. The BHV algorithm was improved helping the engine make better decisions when pairing up 3D models for collision detection. The MVC (Model-View-Controller) flow of information was also improved.

By Dec 2016, I developed the second demo which focused on showing the collision-detection features of the engine:

By Jan 2017 I implemented a very primitive particle system. The particle system was so rudimentary that I completely rewrote it later on.

In this beta version v0.0.4, I implemented a primitive particle system, thus allowing explosion effects to occur once a missile hits the asteroid. I also enabled multi-touch, this allows the spaceship to turn as it speeds up. I also set up collision filters among object types. For example, object A and object B can collide; object A and object C can collide, but any collision among object B and Object C is ignored.

A huge learning moment

From Jan 2017 to Jun 2017, I wasted my time developing a soccer game. The idea was to create a soccer game so that I could improve the engine. However, I soon found myself spending more time coding the gameplay, rather than spending time fixing other issues in the engine.

And this was a huge learning moment for me. I realized that I should not waste my time coding a gameplay. And more importantly, that each game I develop, must serve a purpose towards the improvement/testing of the engine.

Porting to Metal

By Sept 2017, the game engine got a total makeover. From Jun 2017 to Sept 2017, I worked on porting the engine from OpenGL ES to Metal, Apple's Graphics API. The porting was not hard at all; I have to say that Metal is a lot nicer and cleaner to work with than OpenGL. I was surprised that I ported the engine in less than four months.

This video shows the game engine using the Metal API for its rendering operations. The game engine no longer uses OpenGL.

Since I already had the soccer game demo, I used the same game (with different 3D models) to test the engine with Metal.

Why render what you can't see

By Oct 2017, I worked on a feature that I should have worked on years ago. For most of the development, I had put Frustum Culling aside. The idea of Frustum Culling is that there is no point for the engine to render entities that the camera can't see. Implementing this feature improved the engine's FPS (frames-Per-Second).

Improved the rendering efficiency of the game engine by implemented Frustum Culling + BVH tree algorithm.

A true Particle System

Earlier, I had mentioned that I developed a primitive particle system. Well, by the end of Oct 2017, the time had come for me to implement a real particle system. I had fun working on this feature.

Added particle system to the engine. The engine can generate smoke, explosions and other particle types.

Memory Leakage is not acceptable

And finally, by Nov 2017, I fixed several memory-leakages in the engine and a rendering ordering issue with the engine.

In version v0.0.8 of the game engine I fixed some memory leakage issues and improved the rendering-ordering algorithm.

In Conclusion

I've been working on my game engine for more than four years now. It took three years to develop a basic framework. And an additional year to improve the engine. And I'm still not done with the engine.

I hope that this post can give you a sense of what awaits you if you decide to develop your game engine.

Thanks for reading.