A psychological trick to help you develop a game engine

Is going to be almost six years since I decided to develop a game engine. When I started, I knew that it was a crazy idea, and many people thought it too. But looking back, the craziness was not related to the technical complexity, but in the psychological battle that I had to fight with myself.

Throughout the development of the game engine, the desires of giving up was a constant thought. There was a period that I wanted to give up every single day. The constant whisper of "Just Give Up" was always present. And I did give up. I quit for about four months. It was just too much to bear.

But I came back to it. After my sabbatical, I started wondering "What would it feel, if I didn't give up," and "How would the engine look like in a year from now." The excitement of working on the engine again was slowly growing. But there was something that had an impact on my psychology.

Since the beginning of the development, I documented the progress of the engine through images and videos. One night, I started watching these videos. I watched all the small progress I've made and the slow evolution of the engine. Seeing with my eyes how far I've come, had a psychological impact on me. It gave me the energy to continue with my crazy decision to develop a game engine.

Here is a video of the evolution of the Untold Engine, from its inception five years ago to today.

 
 

Documenting my work have been a tremendous psychological tool. It has helped me keep going, and I hope it will continue doing so.

If you are embarking on a complex project, document your work through images and videos to remind YOU how far you've come when you are about to give up.

Thanks for reading.

How to approach Game Engine Development

A couple of weeks ago I was assembling a new piece of furniture for my apartment. As I was putting all the pieces together, I made sure not to tighten the screws until all the parts were in place. Such workflow reminded me of the process I took to develop the Untold Engine.

If you have been reading this blog for a while, you would know that when I started developing the game engine, I knew very little about Computer Graphics. Moreover, my C++ programming skills were weak.

Keeping into account my technical weaknesses and my desire to learn, I approached the engine's development the same way you would assemble a new piece of furniture. That is, I made sure not to tighten the screws until the end.

What do I mean with this phrase? I didn't focus on Perfection. I didn't write each piece of code to the highest standard possible. Instead, I focused on writing code that was Good Enough.

For example, the Collision Detection System is the most complex component you will have to implement. This system requires you to implement several algorithms such as the GJK, BVH, Sutherland-Hodgman, etc. My initial implementation of the GJK was very crude. However, instead of making it Perfect, I decided to move on and implement the Sutherland-Hodgman algorithm. Again, my implementation was crude, but it was Good Enough. Finally, I implemented the BVH algorithm.

I had all the major components working. Their implementations were crude, but they were Good Enough to detect a collision. I had in my hands a crude Collision Detection System, but I had learned a ton in the process. I learned how all these algorithms worked together to detect a collision.

After I understood how these algorithms worked together, I went back and re-read several chapters on Collision Detection and several articles on the algorithms mentioned above. Armed with new knowledge and experience, I was able to improve the Collision Detection System. I think I was able to do so because I saw the system from a holistic point of view. I understood the system weaknesses and strengths. I was able to see the whole picture.

Developing a Game Engine is tough. There is a lot to learn, and you will make tons of mistakes. In the beginning, avoid Perfection. Once you have a good grasp of what you are doing, go back and improve your code. Just like assembling a piece of furniture, do not tighten the screws until the end.

Languages required to develop a game engine

A while ago I responded to a question on Quora regarding which languages are required to develop a game engine. In this post, I want to expand on my answer.

The one thing to keep in mind while developing a game engine is EFFICIENCY. And it was the closeness of C++ to the bare metal that finalized my decision to use it as the primary language of Untold Engine. The other motive was my desires to learn C++ at a deeper level.

Collision Detection is the most expensive operation in a game engine. A proper Collision Detection System must detect a collision, compute the where the collision occurred between two convex entities and compute the collision responses. Furthermore, to efficiently detect collision among several entities, a game engine should parse the scene and divided the detection between two stages: Broad and Narrow Phase stages.

 
collisiondetectionphase.png
 

Such operations require the implementations of a Boundary Volume Hierarchy algorithm and a GJK algorithm. These are expensive operations, and they must be computed within a fraction of a game-tick.

Therefore, whatever primary language you decide to use in your engine, make sure that it is a fast and efficient language. The last thing you want is for your game engine to waste valuable time in the collision detection due to the inefficiency of the language.

Aside from the game engine, you must also develop an application that acts as a bridge between your engine and 3D modeling software, such as Blender 3D. The primary purpose of this application is to export rendering data of a 3D model from Blender and make it accessible for the engine to use. To develop such an application, you need to learn Python-Blender scripting.

castledae.png

During the development of the Untold Engine, I had to develop this application, which I call Digital Asset Exporter (DAE). The DAE not only exports rendering information but also 3D animation data which the engine can use.

daedata.png

Depending on the 3D Modeling tool which you decide to use, you may have to learn a different second language such as javascript. For example, if you choose to use Cheetah3D, you will need to develop the DAE using Javascript.

Well, I hope this helps.

Managing your schedule to develop a game engine

A while back I received an email from a reader asking me how did I manage my schedule to develop a game engine. I feel that his question is a common question among most of us.

So how did I do it?

The development of my game engine can be divided into two periods: "Prior the development of the Basic Framework' and "After the development of the Basic Framework" of the engine. By "Basic Framework," I'm referring to a game engine that has the four primary components implemented. Such as Math Engine, Rendering Engine, Physics Engine, and Collision Detection System.

Time Management Prior the Basic Framework

When I started the development of the engine, not a single free hour was wasted. I had only one goal in mind, and nobody or nothing was going to stop me. My schedule was very extreme:

  • Wake up early in the morning, usually at 5 am and work until 7:00 am or so.
  • Head to work
  • I tried to eat lunch at my cubicle as I worked, and used my lunch hour to go to Starbucks (or Coffee Bean) and worked on the engine
  • Go back to work
  • At around 6 pm, I would head to the Gym or play soccer for about an hour and come back home
  • Work on the engine from 7 pm to 1 am or so
  • Repeat

During the weekends, I would work on the engine for about eight hours each day.

Looking back, I think that I was taking my desires to develop a game engine a bit to the extreme. I should have relaxed a bit more. However, back then I felt that it was the cost of doing what I wanted to do.

Time Management After the Basic Framework

There is something about Game Engine Development that you should know. Once you implement the Basic Framework of the engine, everything gets easier. Developing the Basic Framework is the hardest part of a game engine. Trust me.

My schedule during this period is more relaxed. I no longer put an inordinate number of hours on the engine. I work on the game engine for about 2-3 hours each weekday. During the weekends, I may work 5-6 hours total.

Looking back, I realize that I was able to do all this because I have no other obligations aside from my full-time job (I work as an engineer). I am not married, I have no kids, and I'm out of college. So, I have a lot of free time. I understand that many of you may not be in my same situation.

So, back to the original question: "How can you manage your time to develop a game engine?"

I can't tell you how to manage your schedule. My situation is different than yours. However, the one tip I can share with you to make the best use of your time is this:

Do not code right away. I have realized that after I learned a new concept, and try to implement it in code right away, I would end up wasting a lot of time fixing bugs. Instead, try to internalize the newly learned concept. Visualize the implementation as you are heading to work or school, while watching Netflix, while eating, etc. Think about it as long as is necessary. Think about how it will affect the architecture as a whole. Try to foresee what bugs will arise and how other components in the engine will be affected. Once you have a clear idea of how to implement the new feature, then open up your laptop and start coding.

You will realize that the time spent visualizing the implementation leads to less time being wasted fixing bugs.

So, do not code right away, instead try to visualize it first.

Hope this tip helps.

Tips to make Game Engine Development a joy

Developing a game engine is an insanely complex task. Not only will you spend thousands of hours trying to get the first version of your engine to work, but it will also test your persistence. Thus, developing a game engine is more of a psychological feat than a technical one.

Before you embark on this journey, I have some tips for you.

Play with other engines

Before developing your engine, spend some time developing a couple of games and using a couple of game engines. Use this experience to gather features that you like and dislike from each engine. For example, you may like how friendly an engine's API is versus the other.

Keep this in mind: Developing an engine does not only mean implementing amazing graphical features. It also means developing a user-friendly API which developers love.

View it as your favorite hobby

Again, developing a game engine is insanely difficult. I can't even express how difficult it is for one person to develop one. And not everyone has the stomach to work for thousands of hours before seeing their creation come to life.

So, if you want to see this through, you need to view engine development as a hobby. Don't rush, just sit back, open your laptop and enjoy. It may take you one year, two years, five years, who cares. Just enjoy and fall in love with your engine.

Is OK if some features are half baked

Not every feature in your engine needs to work correctly. Not in the beginning anyway. If rendering Shadows work 70% of the time but fail within some conditions; make a note of it, take a break and move on.

Don't kill yourself over it. Remember, this is your hobby, your favorite pastime. You have no deadlines, no nothing. All you need to do is promise yourself that after a while you will come back to fix the issue.

It is important to consider that when you start the journey to develop your engine, you will not know everything about computer graphics. And you will not know what you don't know.

Features may not work as you hoped for initially, but this is OK. It is a process of failing and learning. Let me give you a recent example.

Last week I ported the engine from OpenGL to Metal. As I was doing the porting, I noticed that some implementations I had done a couple of years ago were incorrect. At the time, I thought that they were correct. But the experience that I've gained over the years spot these mistakes right away.

Don't let perfection immobilize you. If a feature is not working 100% as you intended, make a note of it, take a break and make a promise that you will come back to fix it in the near future.

Thanks for reading