r/Unity3D • u/GrumpyBullGames • 2d 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)
2
u/Nekokatu0112 1d 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!
2
u/swirllyman Indie 1d ago
Using VATs? Would run on mobile too if you are.
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/redfoolsstudio_com 3h ago
Thats so many 😆😆❤️
-10
u/N1ghtshade3 Programmer 1d ago edited 21h 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?
1
u/destinedd Indie, Dungeon Quest, Marble's Marbles & Mighty Marbles 1d ago
looks like plenty to kill!