3D Game Engine Design
I talk about developing the 3D game engine - billboards, cameras, tagging, game objects & more.
June 1st - Billboards
Billboards are a cheap way to get a 2D image to look 3D - forcing the 2D image to face the camera. 2D is cheaper for the GPU to compute, so many billboards is more frames than many 3D models. If done right, the look
I’ve finally added billboards, including Y-Locking billboarding - that ramped everything up a visual notch. Grass and other 2D objects look convincingly 3D using this technique. I’m definitely excited to try it out. I’ve had an idea for a low effort low poly game for quite some time using this kind of art style. Now I finally have the medium to deliver it with.
Some assets used are not created by me, and will not be in the final game, this is developer footage onlyJune 5th - CAMERAS, CAMERAS, CAMERAS, CAMERAS
I handle 2D interfaces by simply having a hardcoded secondary camera called UI\_Camera - this camera is programmable, so I can move it anywhere, and assign specific objects to only be visible to this camera, allowing the UI to draw using 2D elements in the 3D space.
I finally decided to add transparent texture support, this caused a few headaches but nothing a rewrite of the renderer wouldn’t fix. Since everything is abstracted into components, rewriting it is extremely easy.
I’ve also added a quick real-time 3D camera frustum renderer so the cameras are a bit more usable without having to actually preview the camera shot every single time.
Some assets used are not created by me, and will not be in the final game, this is developer footage only
FPS has been improved, along with large load times for a scene with 512 images. (Tree testing)
I saw a video about GTA 3 debug scripts (https://youtu.be/1w_7zmTbOKA?si=DZEcbI_015n-5Wr5), and got inspired to add the “Show Collision Polys” aka gbShowCollisionPolys. This mode is more of a novel feature than anything real right now, but I know it will be helpful in the future to solve map collision oversights.
Some assets used are not created by me, and will not be in the final game, this is developer footage onlyI started the concept of brushes, I have a lot more planned, but the end concept is just automatic object placement. Duplicating existing game objects to make mapping slightly easier.
Some assets used are not created by me, and will not be in the final game, this is developer footage only
Rendering in general is essentially exactly how I want it. I can use cameras as rendering layers, or I can use them as reference points for the main or secondary camera. This means I can setup the scene using both 2D and 3D side by side.
Collision now has a selector that can be used to define how it’s processed. This is useful as the mesh collision tends to use more CPU in general.
Some assets used are not created by me, and will not be in the final game, this is developer footage onlyJune 13th - Tagging
Something I’ve been trying to solve is not getting into the pitfalls Unity did while still trying to implement some of the major things they have that made development inside of Unity easy. The editor is key to all of that, so I’m trying to make my editor up to par.
One pitfall I always thought Unity had was the tagging system. Maybe this is no longer the case, but tags used to be have to be pre-defined. So you’d have to first manually manage a list of tags, then you would assign each game objects tags from this list.
To contrast Unity with my editor - I want this engine to make things without thinking about how they work too much. Some core components you will need to understand but I want these to have transferrable skills from other engines, lowering the barrier of entry.
June 13th - Scene Graph
I decided to redo how naming works as well. It used to be each scene would have the naming unique, I made it slightly easier for prefabs. Now if you have a scene such as:
UI.scene:
UI\_FPS\_Text
UI\_TPS\_Text
This can be loaded into a scene as:
ui
Then the various children nodes would be defined as
ui/UI/_FPS/_Text
ui/UI/_TPS/_Text
If ui existed, it could import as ui-2
and the nodes would be
ui-2/UI/_FPS/_Text
ui-2/UI/_TPS/_Text
previously I was flattening the scene graph, so I just did:
UI/_FPS/_Text/_2 < as duplicates were not handled at the parent but rather per-object.
Now I’m moving forwards towards utilizing the scene graph, so I’m no longer flattening it. This means I can optimize scenes that are “complex” with many Game Objects in it, by just designing the scene correctly.
June 19th - Shadow Mistakes
Tried to implement lighting with shadows yesterday. 9 hours. I did not like any of the results I was able to come up with, compared to what I already have written. So I rolled everything back to the pre-baked lighting, it looks great and I can pass a simple color to it and at least get basic lighting on it.
Since that was a fail, I spent today rewiring the render engine file, I’ve just been throwing everything in there since I did not have a clear goal of how the components would connect. Now everything is divided into World>Object and World>Editor, good enough for now.
I made a private YouTube channel so I can upload longer development videos on there. Normally whenever I prototype something new, I take a quick video of it. It might be cool to just list all of the videos public one day - lots of weird and wacky shit there.
June 22nd - 3D Engine Thoughts
Finally figured out what caused OBJs to look so weird. Now they’re looking just as good as the GLBs, so I paused GLB to focus on the general lighting and shading - GLB has their own issues with view space I need to correct, but eventually I want to move everything over to GLB format since it can handle lots of niche shit like lighting objects, cameras and things like that
Right now the shadows look incredibly convincing, but they don’t cast though so objects in-between a light source don’t cast their own shadows yet.
Really happen with the results so far, I’ve included some screenshots of what I’ve been able to create with the engine.
Some assets used are not created by me, and will not be in the final game, this is developer footage only
June 23rd - GameObject Refactoring
Today I started refactoring the GameObject to follow more Component-System-like. My object tracking now resembles an Entity Component System (ECS).
I’ve gone through several iterations and here are my thoughts:
ECS Map - Using a map (like
Enum -> Component) works well if you need dynamic lookups. But since my data is fixed, a map is entirely unnecessary.ECS Arrays - Similar to maps but using arrays with manual index management. Again, unnecessary for fixed data.
God Object - My original design and this is (dumb).
ECS Variables - This is essentially what I had with the God Object, but now I can move variables and functions into specific dedicated component classes. It’s a balanced to where you have forced structure, but it’s still not fully dynamic. I’m not supporting dynamic types, and if I need more components, I’ll just extend the enum. This isn’t a library, so extending the engine is expected to be done via source code edits, not runtime extensions.
Combine ECS Variables with multiple lists based on object type, that are culled relative to your coordinates - You end up with a powerful & fast ECS-like system without unnecessary complexity.
June 24th - Shader Hot Reloading
When you modify your shaders in a text editor, the game engine can reload the shaders, restart the shader, then re-initialize the variables. This process is seamless but when paired with a FileWatcher service you get a very powerful and low cost way of managing shaders from the editor. Obviously this cannot be suited for the release gameplay - but while the scene is rendering in the Editor mode, this is perfect.
I’ve been experimenting with lighting and shadows to get the perfect feel. I think a strong visual look is key. I don’t want my 3D games to look like every other game out there right now, using the same lighting, shadows, and rendering. Obviously there are exceptions to this rule, but games are being more “mono” as we move towards unified engines for every single release.
Some assets used are not created by me, and will not be in the final game, this is developer footage only
June 30th - Month End Summary
??? Completed Tasks
I have stopped keeping track of tasks for now. It’s a really kind of refreshing state, where I can just focus on development without worry of achieving any specific goals.
As a recap from this month:
- I’ve paused work on the 2D game.
- 2D GPU render for the OS has also been cancelled for now.
- I’m going to focus on making a 3D game within this OS.
- This is also going to be the last month end summary.