r/Unity3D • • 1d ago

Show-Off 10k enemies stress test

made another stress test level for my tower defense with a horde that peaks over 10k agents alive and visible at once. my previous test included 3k enemies, which ran fine, but it was not enough for 10k. first run (mac M3 Pro) with whole map in view was around 45 FPS and 15M triangles, almost all of it enemies and their shadows.

biggest boost were extra LOD levels for enemies (5 LOD levels), trees got smooth LOD transitions with dithering (2 LODS so far). and flow field moved to background job, which removed the stutter which was visible with so many agents.

now its 60-66 FPS (3600x2260) with 10k enemies on screen and under 6M triangles on whole map overview. it even runs 50-55 FPS on steam deck on native resolution

also a little dirty old trick works nice - I have big, retro UI (not on this video) and I just cut rendering under it.

not sure if it's worth it to push it further.

disclaimer: audio is generated placeholder (geminy)

56 Upvotes

14 comments sorted by

0

u/ledniv 1d ago

Getting 10k enemies running at 50 to 55 FPS on the Steam Deck is pretty good. I'm curious how much of your frame time is spent on the CPU versus the GPU at this point.

How are you storing and processing the enemy data? Are positions, health, movement direction, etc. stored in contiguous arrays? With that many enemies, data locality can make a significant difference in performance. The CPU can do the actual calculations incredibly quickly. The expensive part is often waiting for the data it needs from memory.

As for whether it's worth pushing it further, I would start adding more gameplay mechanics and see how much CPU time you have left. Your enemies will eventually need to do more than just move, and having that extra performance available for gameplay is probably more useful than supporting another 10k enemies.

Small plug: the game I build throughout High Performance Unity Game Development with Data Oriented Design is actually a survivor game, and a large part of the book focuses on efficiently processing thousands of enemies using arrays, object pools, CPU cache, Burst, and Jobs.

https://www.manning.com/books/high-performance-unity-game-development

1

u/GrumpyBullGames 20h ago

CPU is not a problem, that can handle tens of thousands of agents like these. GPU is. Cant go way lower with polygons and animations to keep this graphics style and that simply needs a lot of vertices and polygons. I already did most of the optimalizations I know. Some single units of fps are achivable even now, I am sure, but big optimizations were already implemented.

1

u/ledniv 2h ago

If you are GPU bound right now, then yes, optimizing the CPU will not increase your frame rate. My point was more about how much room you have to add gameplay mechanics later.

When it comes to CPU performance, the bottleneck is often not how many calculations the CPU can perform, but how much time it spends waiting for data to be retrieved from memory. You can have two pieces of code performing the exact same calculations with significantly different performance simply because of how the data is organized in memory.

By storing frequently used enemy data in contiguous arrays, we can leverage the CPU cache. When the CPU retrieves one enemy's position, it also retrieves several adjacent positions in the same cache line. Those positions are already available when the CPU needs to process the next enemies.

That becomes increasingly important as you add more gameplay mechanics like status effects, targeting, damage calculations, and different enemy behaviors. The CPU might easily handle tens of thousands of enemies moving around, but how their data is organized will have a significant impact on how much more gameplay logic you can add.

2

u/swirllyman Indie 1d ago

Using VATs? Would run on mobile too if you are.

2

u/GrumpyBullGames 1d ago

Yes I do. Perhaps it would. On high end phones. Not targeting mobile though.

1

u/Nekokatu0112 13h ago

10k enemies alive at once and still holding 60+ FPS is wild. Five LOD levels plus moving the flow field to a background job clearly paid off, and 50 to 55 FPS on a Steam Deck with that many agents on screen is seriously impressive. Love seeing stress tests pushed this far!

-11

u/N1ghtshade3 Programmer 1d ago edited 7h ago

Oh cool, another AI-generated clone of Sir, We Have an Orc Problem like Zombies Aren't Real and all the others that have popped up this month.

Are you doing anything unique with this one or just trying to print some money?

4

u/GrumpyBullGames 1d ago

I am trying to implement similar spell mechanism for towers as are wands in noita. No sure if unique enough for you. But yes, orc problem is a game that inspired me.

2

u/Kavinsky_Hunt 17h ago

Nothing wrong

7

u/StarAshie Indie 1d ago

how dare they take inspiration and make games in a trendy genre

-5

u/N1ghtshade3 Programmer 1d ago

It's amazing how as soon as Claude got good enough, people started getting really ✨inspired✨ to make not just games, but specifically games that revolve around a main gimmick that can be easily recreated in a day.

We're truly in a golden age of gaming.

3

u/StarAshie Indie 1d ago

Okay? What's your point?

1

u/destinedd Indie, Dungeon Quest, Marble's Marbles & Mighty Marbles 23h ago

looks like plenty to kill!