First Jobs Prototype


I started this project to learn how to program in ECS. I am not disappointed that I did.

One thing I had always been intend on doing was creating boids (flocks) in ECS. ECS is meant for a large set of entities doing the same thing and flocks are a large set of entities doing the same thing. So it is the perfect use case.

To get me started, I've been using hecomi's ECS boids that I have implemented and tweaked where necessary. What I really like about his method is that it is rudimentary; setting a solid foundation, but leaving room for improvement. He implements a system where boids move freely within a cube, evading one another. I'm hoping to implement collision evasion, focus points and wall meshes. (And if all goes well, even make it run inside the editor, though I think that's a pipe dream.)


But enough boring talk: lets see some results!

Here is a 100 boids! This still worked well with a classic object oriented Unity implementation. The ECS implementation however was running at 130 fps!

A 1,000 boids would break classic Unity... not ECS!

Surprissingly, a 1,000 boids was STILL running at 130 fps! Now there might be a lot of reasons for this (not excluding magic) but the point is, I think we can all agree, it's a hell of a lot faster than 10 fps.

Only when I reached a 100,000 boids did my laptop start to think "that's quite enough" and come down to 35 fps.

And if 60 fps is more your speed, I think 10,000 boids is still not an unreasonable number! Probably more than 10,000 but I didn't test that.


And you know what is best about all of this? I have only just started! There is loads more fun to be had with ECS and I am excited to find it! I 'even' think that there is a way to make these boids run even faster than they are now! I just don't know if I am up to the challenge of writing parallel jobs... but there's only one way to find out.

Cheers!


P.S.
For those of you technical enough to care (myself included), here are my specs:
Unity running on an NVidia GeForce GTX 1060 gpu. The boids make no use of physics or colliders. The boids were all casting and receiving shadows, with 1 realtime per pixel directional light source in the scene, of 2048 resolution. I used the Universal Render Pipeline using a forward renderer and the SRP batcher enabled. My boid material was GPU instanced. My laptop was plugged in for every test.

Leave a comment

Log in with itch.io to leave a comment.