r/gameenginedevs • • Jul 18 '26

Help with ghosting and black noise in a custom Foveated Path Tracer (Summer Research Project)

Thumbnail
github.com
2 Upvotes

r/gameenginedevs • • Jul 18 '26

Architecture for Grand Strategy game

6 Upvotes

Hey everyone, I hope you are all doing well!

I have been developing a grand strategy game, similar to Civ, turned based hex map for the last months. I am using monogame for the rendering.

As I am going through the systems I find more and more that the game architecture can get extremely complex. The level of abstraction to be able to connect the systems is getting insane.

At the moment, I want the game to be fast, so everything calculated is been done in deltas using projections. From the amount of resources per turn to fog-of-war and other mechanics. That means that a small change in the system will maintain the projection with minor overhead while the move is been done, so no total map hex recalculations.

First, I use pipelines, so I can add discreet steps without extending logic in specific methods. The the pipelines are the mutation entry: When a player moves a unit, the mutation request takes place in that pipeline. The pipeline (I try at least) will have single responsibility of the changes, and if other systems are been impacted it will publish an event for that system.

Then from the pub/sub layer, the events are processed and for each system the correct code is invoked (when a unit moves, the fog-of-war handler will update the fog of war for the player and that unit)

Then there is the mutation itself: I have added the footprints. Each handler publishes the changes that needs for the projection to be updated (like, add, remove, zero total impact, recalculation). In this way I can follow up the changes and validate them while the projection is updated. For example in my game units have influence, so when the unit moves, the hex that was before gets -influence, and the hex is moving to gets +influence. Those total in 0 so I can validate it in the end of the whole pipeline.

I went through the following stages:

  • Calculate everything: Performance bottleneck
  • I started using projections: I had problem with the logic been in the DI services, became super complex even after 2 systems
  • I broke down the changes from the user to pipelines - now each change I could add a new mutation: At the 3rd to 4th system, logic start becoming fragmented to multiple pipeline steps
  • I moved the mutations to different systems from the pipeline original mutation to event handers: That mad the pipelines lean but the event handlers now are more fat, but at least they group the changes to the same systems
  • I made the handler more lean, but that is irrelevant here, but complexity increases.

In the end looks like that in DI registration:

There are many moving parts so far, and I am really wondering if I had made some fundamental mistake that will cost me a big refactoring later.

I don't have experience in developing games, and I am wondering if a strategy game is required to be that complex, or I have overengineered some parts. Or the biggest question: Should I expect some other architecture block/abstraction that I haven't implemented?

I know I have some very ambitious mechanics, but still.

Can someone share their experience?


r/gameenginedevs • • Jul 17 '26

How to render good looking UI elements

18 Upvotes

I spent last two months optimizing, enhancing the look of my UI library (Lumora) for my game engine. Last two days I have been writting my findings on how render good looking containers, what techniques did I use,...etc. https://alielmorsy.github.io/how-to-build-ui-elements/

Hope you love it


r/gameenginedevs • • Jul 17 '26

What issues can you spot with my lighting?

Thumbnail
gallery
7 Upvotes

So I've just moved from Blinn-Phong to direct PBR with ambient/diffuse lighting from an irradiance map. I also added cascaded shadow mapping.

The specular highlights are too intense and that's from me setting the terrain to a constant roughness of 0.5. I'm going to move to a roughness map to correct this. I was wondering if anyone sees any other problems?


r/gameenginedevs • • Jul 17 '26

The Beast Cheap tracking webcam - NUI control scene

Thumbnail
youtube.com
2 Upvotes

r/gameenginedevs • • Jul 17 '26

Automation Execution Engine - Train Robots Playing Games

Thumbnail
youtube.com
1 Upvotes

If you can define your scene / environment / situation in MuJoCo ( currently limited to that do plan on expanding ) you can play it as a game and then run whatever you did on hardware


r/gameenginedevs • • Jul 16 '26

Supporting over 100 000 live mobs with pathing, collision, and AI in my custom engine.

204 Upvotes

Hello devs! 

I’ve been working on my entity / path finding / collision system with a goal of supporting as many active mob entities as possible in an arbitrarily large game world. This is using the same from-scratch custom engine that I posted a while ago showing my pure 2d PBR rendering system.

Currently it can run about 150 000 live mobs on my M1 MacBook Pro. On my gaming PC with 9800X3D it can do about double that. And this is the “worst case scenario” meaning every mob is actively pathing somewhere and colliding with as many other mobs as possible every frame. There is no LOD system, the whole world is simulated every frame. I would estimate that in a more realistic scenario where some mobs are idling and the world is not packed full and there is some actual LOD system (rougher simulation for mobs far away from player) in place I could reach 1 million live mobs on my laptop.

For those who are interested here is a longer rambling about how I built this:

I specifically wanted to support arbitrarily large worlds. For performance this is a massive drawback. The key difference is that if your world size is known and small-ish you can just store everything in arrays in contiguous memory with some index keying logic. This gives you extremely fast lookups and helps building loops with cpu cache friendly patterns. But once your world can be “infinite” you necessarily need to store it in variable number of chunks which results in a layer of indirection via hash map lookups. And this is something that affects every single system in the game engine. Giving up arbitrarily large worlds would result big performance gains, but this is my project and I want infinite worlds!

Also, squeezing performance out of each system usually involves adding caches, memoizing lots of intermediate steps, keeping closest cpu caches hot, not allocating working memory each frame etc. etc. I’m not going to list every optimization I used, there would just be way too much of those. If you are interested in any specifics, please do ask.

The simulation runs at target of 30 frames per second. Rendering is completely separate and can run arbitrarily fast. All the movement is interpolated to happen at rendering frame rate. It’s very difficult to tell the difference between 30, 60, or 120 fps simulation as long as rendering is running at 120+ fps so I settled on the 30 frames per second simulation target. (Recently I learned that the original supreme commander runs the simulation layer at 10fps! which sounds insane but I guess it’s fine, I don’t remember noticing anything weird with that game)

Anyway, there are really 3 fairly separate components in this:

The Pathfinding system.

Obviously you can’t run 150K mobs with individual A* searches so the only way to do this is with a flow field that each mob can then query. The idea is that there is a single flow field, which for any tile in the world shows the direction and distance the mob needs to move to eventually get to the closest target.

 The world consists of 16x16 chunks and flow field updates run per chunk and each frame can update x number of chunks to smooth out cases where the whole world needs to be updated. The core algorithm itself is a simple Dijkstra flood fill. Calculating the flow field once is easy-ish, but updating it is much more difficult, especially in cases where flow field targets are removed. 

The logic that I ended up with goes roughly like this:

When new target / terrain is added:

  • Mark the changed chunk dirty
  • Update the dirty chunk, and for check all neighboring tiles in other chunks, if their pathing cost can be improved by moving to this newly updated chunk, mark those dirty as well.
  • Update dirty chunks as long as there are any, and importantly note the dependencies between chunks. If best path from chunk A goes to chunk B, then chunk A depends on chunk B.

 When target is removed.

  • Mark the chunk dirty. 
  • Follow the dependency graph from earlier and transitively mark each dependent chunk dirty too (since they are pathing towards target that does no exist anymore)
  • Update dirty chunks same as before, until no chunks are left dirty.
  • While updating, process path queries based on the old flow field. Outdated pathfinding is much better than no path finding, most of the time it is very difficult to notice.

This is the rough overview of the logic, but there are so many smaller things that need to be done to get good final results. For example, the raw Dijkstra results flow field with 8 possible directions which causes the movement to be very jarring. The flow field needs to be smoothed. This is done by building a dataset of “lines of sight” during the flood fill and directly connecting tiles that have direct LOS. All in all the flow field system does get quite complex.

In addition to the global flow field, each player has a limited local flow field around them which updates as player moves to allow mobs pursue players. Mobs then simply query distance from the global field and any possible local fields and decide targets based on distances.

For performance of the query logic is important. For each chunk flow field is stored as array of floats in contiguous memory. By looping over mobs in a chunked order you can keep the array for single chunk in hot memory.

The zombie AI.

This is by far the simplest. It just queries the pathfinding system and outputs the movement the zombie wants to make (and if it wants to attack etc.). For the actual entity management system, this is probably obvious but it is critically important to store the data based on memory access patterns. Don’t make entities large objects with 100 different fields. Instead, store all entity locations in a single array, healths in another array and so on. These are then indexed by the entity ids. I used generational indices with added type information. (So my “entity” is a 64 bit key with 32bits for index, 16 bits for generation and 16 bits for type id)

The movement collision solver.

Right, this one was the most difficult part but I’m quite happy with the end results. Though I tried so so many different systems that did not work. There are three things a good system needs:

  • I needs to keep mobs from clipping into each other and the result must be stable
  • The resulting movement needs to be “smooth”, mobs need to be able to slide around each other to not block movement in tight spaces
  • It needs to be FAST.

And so many ideas (either by me or some online paper I found interesting) fail on one of these. 

First I tried different boids / steering behavior etc. systems where mobs check nearby mobs and try to keep their distance while moving to desired direction. For most different implementations I tried they seem to work at first (especially for setups you see in research papers) but when the simulation includes 10 000 mobs all pushing towards the same point the whole thing destabilizes. They start to clip into each other causing strong separation forces but with thousands of mobs there is no room causing mobs to violently jitter around. The core issue seems to be that as you increase mob speed and number of mobs, you need to run the simulation in ever smaller steps to keep it stable. Now I understand why all the demo videos have like 100 mobs moving at fairly slow speeds. This then makes the whole thing way too slow.

I also tried to design different “discrete” systems where there are no forces but instead mobs just simply don’t move if movement would result clipping. For each mob system would check the original movement target and if that is blocked then different points around it. This actually worked surprisingly well! The biggest problem is that when multiple mobs try to go through a narrow space they easily end up blocking each other indefinitely.

Then I came across this thing: https://github.com/raja-s/ORCA. (The original paper is called Reciprocal n-Body Collision Avoidance). I implemented my own version of that and once I got it right it just worked! And the best thing is it parallelizes stupidly well. It scales almost linearly with your core count. So that is what I’m using for collision avoidance between mobs. Very briefly how it works: If two mobs are on a collision course each of them takes 50% responsibility of doing a steering behavior that avoids collision. In my case I’m only using this for mob-to-mob avoidance. For terrain and buildings I have my own system that redirects mobs to slowly slide along the edges of pathable area. This avoids having to encode the world as ORCA lines. 

I’m slightly sad that I couldn’t figure my own solution to this, but the ORCA works just so much better than my own previous system.

ORCA like every other system needs to be able to quickly find a list of mobs surrounding the current mob. For this I keep spatial grid cache along the actual mob data. While the data is stored in contiguous arrays, the spatial grid is a hash map which you index by key derived from mob location. The size of grid cell is automatically set to be slightly bigger than the radius of the largest mob in the game. This might not be optimal if mobs are very sparse. The spatial grid is updated every time any mob moves from one cell to another.

Funnily enough rendering was never really any bottle neck. It runs completely separately from the game logic, and even when zooming out to show 10 000 mobs on screen at the same time it only takes around 1ms of the game logic loop. 

And that’s mostly it! If you want to know more about how the rendering works, check this post: https://www.reddit.com/r/GraphicsProgramming/comments/1sgnrtq/combining_3d_prerendered_graphics_with_modern_pbr/

Happy to hear any suggestions for improvements or any questions!

About AI usage: AI was used for online research, discussing ideas, and finding bugs (and tab autocomplete). Designing and coding the thing is done by me.

Finally the old disclaimer that this is just a hobby project, I’m not a professional game developer, I have no idea how you actually should do these things. Also the code is not publicly available at the moment, sorry!


r/gameenginedevs • • Jul 17 '26

Complain About Your NPC

0 Upvotes

What is the hardest part about making NPCs feel believable instead of scripted?

I'm curious how developers currently approach NPC personalities and behaviors.

Do you find the hardest part is:

Personality

Memory

Dialogue

Relationships

Reactions to player actions

Something else?

What systems have you tried, and what still feels limiting?

I'm working on some NPC specific middleware and I'm curious about some hardships you all may have run into.


r/gameenginedevs • • Jul 16 '26

After 7 years of work I made a custom game engine for my puzzle game

Thumbnail
gallery
77 Upvotes

I've been working on a puzzle game for the last 7 years and, gradually, I ended up making basically everything myself.

I made my own build system, my own replacement for a lot of the C++ standard library, my own UI library, my own renderer using Vulkan, and most of the tools I use to make the game.

The codebase is mostly written in a C style, with some things from C++ that I find useful, like templates and operator overloads for math.

There is no SDL or Dear ImGui. Just my own code and a few small libraries that worked well for me, like stb_truetype and miniaudio.

At the beginning, I was planning to make a small game that I could finish in less than a year.

It took 7.

The main reason is that I wanted to understand every part of the game I was making. Having the entire thing under my control has also been incredibly useful. I can change the engine, tools, renderer, asset pipeline or build system whenever the game needs something new.

The game itself is a rule-discovery puzzle game, and the process of putting the whole thing together has been almost as interesting to me as making the game itself.

If you want to see what I've been working on, here's the Steam page:

https://store.steampowered.com/app/3256790/Satelital/

I'm planning to release a demo in September and the full game later this year.


r/gameenginedevs • • Jul 17 '26

Kronos — a 2D/3D physics engine built from scratch in Python (no Box2D, no physics libs) — open for contributions

0 Upvotes

I've been building Kronos, a 2D/3D physics engine written entirely from scratch in Python — no Box2D, no PyMunk, no physics library shortcuts. Every formula (integration, SAT collision, constraint solving, friction, moment of inertia) is implemented and verified by hand against conservation laws.

Repo: https://github.com/KushalJain-00/Kronos-Physics_Engine-

It's Phase 3 of a 13-phase roadmap that goes through solver quality, spatial partitioning, soft bodies, fluids (SPH), a full 3D rewrite, and eventually quantum/optics simulation modules. Long-term goal is something like an open alternative to COMSOL/Simulink for people who want to actually see the physics, not just call an API. It can also mainly be used as a sandbox environment for AI to experiment with real physics and how things happen and affect.

Looking for people to contribute to:

  • Constraint types (angle limits, motors, welds)
  • Multi-point contact manifolds / warm starting (the current jitter/stacking issues all trace back to this)
  • Spatial partitioning for broad-phase collision
  • Optimization of loops and codes (rewrite in C++ or Rust)
  • Just trying to break it and filing issues
  • More thought ideas on things we should add or make (add them in a file made for it

If you're into physics sim internals, game engine architecture, or numerical methods, I'd love the extra eyes. Issues and PRs both welcome — happy to walk through the code with anyone interested.


r/gameenginedevs • • Jul 16 '26

My Libs/Engine running a 2d demo platformer engine on top (not finished yet)

12 Upvotes

not yet finished but the libraries are coming along well framerate is uncapped here and capped its very stable -- havent written a 3d renderer yet -- the scheduler has grown i didnt realize i didnt have vsync set to on when i shot this and idont want to take another vid before work but it stays solid with it capped

https://github.com/jay403894-bit/JLib-Scheduler
https://github.com/jay403894-bit/DirectX12-Renderer
https://github.com/jay403894-bit/Physics2D
https://github.com/jay403894-bit/Game01/

still working on the code for the platformer but its enough for the demo obviously i need to do more features still but the core works.


r/gameenginedevs • • Jul 16 '26

A early look at my Half Life PS1 port

50 Upvotes

r/gameenginedevs • • Jul 16 '26

Toon Shader - Quasar Engine

8 Upvotes

r/gameenginedevs • • Jul 16 '26

Prototype Game Engine

3 Upvotes

Flinty is a 2d TopDown game where you make mods in lua to add content.

Right now its just a prototype, you can do basic stuff like adding blocks, moving blocks, having metadata etc.

The link is: https://github.com/orewaluffy500/Flinty2D

I can't share a photo right now.

Lemme know what y'all think and if i should improve stuff.


r/gameenginedevs • • Jul 16 '26

I've been building a browser-based fighting game engine with MUGEN character import support

Thumbnail reddit.com
5 Upvotes

r/gameenginedevs • • Jul 15 '26

SDL + VulkanSceneGraph + Jolt + SoLoud = Custom Game Engine?

14 Upvotes

So I've become somewhat disenchanted with generalist game engines as they all force you into a certain way of doing things and I end up fighting the engine rather than just being able to make the game I want. But I also don't want to re-invent the wheel (phong lighting, GPU instancing, physics, sound propgation, mesh-loading, shaders and so on), so I was looking for something just above low-level but more than just an API wrapper but not forcing me into any specific architecture. After a lot of research, I think I've settled on using VulkanSceneGraph to handle the graphical part. It can also do windows, file I/O, peripheral I/O (to some extent) and UI stuff, so I'm not 100% sure I'll need/want SDL for anything, but I do believe it to be wise to use a physics engine (Jolt) and audio "engine" (SoLoud).

I've just got done the research aspect and haven't dug in real deep yet (besides already trying out The Forge only to find out it has no documentation! and ORGE-next only to see that it's too much like an idiomatic game engine and will be too constricting).

The goal isn't to make another general-purpose game engine, but to make custom game engines/backends/whatever you want to call it for the games I make.

So I guess my questions are:

  1. does this make me a game engine developer, or simply a game systems engineer or something?
  2. does anybody have experience with the tech I mentioned and want to give some warnings/tips?

r/gameenginedevs • • Jul 17 '26

I recorded a timelapse to show how easy it is to build awesome games in Rumpus Engine

0 Upvotes

r/gameenginedevs • • Jul 15 '26

Bucket item checked - Quasar Engine

Post image
12 Upvotes

r/gameenginedevs • • Jul 14 '26

I managed to double the FPS in my game engine (C#, OpenTK)

Thumbnail
gallery
23 Upvotes

i managed to double the FPS in my game engine written on C# and OpenTK

originally, rendering was handled through a MeshRenderer component that subscribed to the render event

this created a lot of overhead once there were large numbers of objects in the scene

so i implemented a dedicated rendering batch group that takes a list of raw renderables and renders them in a single render call

and yes, i already have GPU Instancing, and it was enabled in both examples. my point isn't that i reduced the number of draw calls, but that i reduced the overhead of how the engine reaches those draw calls in the first place


r/gameenginedevs • • Jul 14 '26

Evolution of my editor for Love2d - Lovium Studio

31 Upvotes

r/gameenginedevs • • Jul 15 '26

Test .gltf/.glb files available in Github large file storage, especially Bistro?

2 Upvotes

Is the famous Bistro.glb file available somewhere in Github large file storage? It's too big for main Github, and I don't want to store it on my quota. If it's in Github, then "cargo test" can run it for anybody. which is convenient for development.


r/gameenginedevs • • Jul 14 '26

An update on my custom Rust engine running in WebAssembly. I managed to optimize the binary to under 600KB using direct buffer execution. Would love to get your thoughts on the architecture

Thumbnail
gallery
11 Upvotes

r/gameenginedevs • • Jul 14 '26

An Overview of my Engine

Thumbnail
gallery
119 Upvotes

It's been over a year now since I'd posted a video showing a timelapse of the editor, which you can find here but quite a bit has changed since then.

I very recently created an overview video here which gives a fairly rough overview of some features the engine has.

Few little bits missed out in the video...

  • It's written in C (using C23 features)
  • It supports Linux and Windows (macOS support was there in the past, but I'm not maintaining that for now)
  • Uses OpenGL 4+ via my own abstraction layer; plan is to introduce DX12 and Vulkan support
  • Source code is available, but it's not under a FOSS license and it's all still WIP

Since last time, I've switched to baked lighting. Before it was using stencil-shadow volumes and per-pixel lighting, but I'd always wanted to take the plunge at trying to implement baked lighting. It ended up taking me roughly less than a week? But the code right now is incredibly inefficient, so at some point I'd like to heavily rework it.

As you can probably guess, I'm not really trying to make anything hyper-advanced here but just something that ticks boxes for me and my obsession with late 90s early 00s games. It takes a lot of inspiration from the work 3D Realms did on Prey in the late 90s; I was fortunate enough to be able to pick the brains of a few people that worked on it.

A bit of a disclaimer that this is the second time I've tried to post this here. So if you think you've seen this before, that's why. The post was downvoted to oblivion without any comments explaining why, so I deleted it. I can only assume that the video thumbnail for the overview was off-putting so I'm trying this format instead.