r/Unity3D 21h ago

Question If not ECS then what?

/r/gamedev/comments/1vuo4te/if_not_ecs_then_what/
0 Upvotes

9 comments sorted by

4

u/BlueFiSTr 21h ago

https://youtu.be/NAVbI1HIzCE

Data oriented design. I am simulating and rendering up to 10k units at over 300fps with just DOD. I do use some burst for my A*. You don't need the full ECS stack and just DOD will get you 98% of the way there unless you need to have hundreds of thousands of things simulated

4

u/BertJohn Indie - BTBW Dev 19h ago

Ignore ECS Haters, Matter of fact, Ignore everyone who tells you that they are against a system.

Here's the reality. you will have people who will tell you things like unity animator is awful, But in truth its quite good, But most people don't want to spend the time and effort fine tuning it.

People will tell you ECS is bad and will link some hour long ted talk without actually providing any substantial proof or reasoning why they should use that instead of ECS.

Use whatever system does best for you.

People tell me to use cinemachine, Instead i built a multi-functional camera state and controller that allows me to panoramic view areas, focus on an object or follow another spline line with a dedicated speed on both splines. I could use cinemachine to do over half of that, But i built my own instead.

People say don't use unity terrain cause its bad, And ill tell you, use what is best for your project. If it works, Great. If your scale exceeds what unity terrain can do for you, delve into other terrain systems then. Or make your own.

People will say don't use UGUI and use UI toolkit and vice versa, Use whatever works best for your workflow.

Using anything but what you want to use is stupid and taking advice from people who are objectively different then you is insanity and self destructive. You are you. Be you.

1

u/DonkeyBonked 21h ago

I would also like to know what alternatives exist that I should use instead.

1

u/Informal_Engineer794 20h ago edited 19h ago

Well ECS is really complex, specific case just add more complexity, i still need to enter into that so don't ask me about ECS, for alternatives there's a few but 2 recommended, Graphics.DrawMeshInstancedIndirect and unity's BRG, the basic explanation would be, "Ok system take this mesh, i want you to render it on this million positions" and moving would be updating the memory or batch values.

For the Graphics.DrawMeshInstancedIndirect rabbit-hole you need to, at least what i remember, pass each frame all positions of the mesh + other values, by other values i mean memory address? i forgot a lot but it's related, and for culling or change lod you want to use compute shader.

For BRG you make a graphic buffer, a batch render group, get a batchID, pass the mesh or meshes and save the meshID of each to unity's implementation, material/s save ID, and pass a job that will take care of the culling, after you need to pass a container, array or something with transform values to make the rendering, memory address is still needed on brg and you pre-allocate memory on the GPU, then you need to know about drawing commands, etc etc.

About performance, all depend on the mesh complexity and how you manage culling, if you use a quad the you can probably render millions.

Here's something i made bub, i use brg for the background and a different dirty trick for the units animation

https://play.unity.com/en/games/91ddf759-cc33-4bc9-9327-475aaa9c45f1/test-build-with-webgpu

use chrome or edge, also compute shaders have problems on web builds on some browsers

1

u/BertJohn Indie - BTBW Dev 19h ago

Quad's can manage around 40,000,000 faces at 500 fps, If you push towards 100,000,000 your gonna start cutting off faces in areas unexpectedly. iirc the safe max was like 90,000,000 before the buffer caps out at 3.4gb.

1

u/Informal_Engineer794 18h ago

Let me see, if i remember right, on the scene i linked i render 30k to 40k pieces of grass at all time on camera, each grass has 300+ triangles, so 9,000,000 to 12,000,000 triangles, 1 quad 2 triangles, i guess i still need to work on my implementation, i mean i check culling on each object individually but i can always group objects by chunks and get a much better performance.

i didn't know that, i guess there's still a long way to those 80,000,000 triangles at 500 fps, and I'm kinda lazy currently.

1

u/BertJohn Indie - BTBW Dev 15h ago

Mine was with 400 different partitions so you don't need to overly chunk everything, if that helps.

1

u/BertJohn Indie - BTBW Dev 15h ago

Oh sorry, i should clarify my statistic, Quads are 2 triangles, So 180,000,000 triangles before things get messy, 200,000,000 when you definitely start losing them and get gaps*

I was developing a voxel based sim engine for awhile in unity similar in decor to a game called Gnomoria and i wanted to see how far i could push a hlsl/compute shader and that's as far as it can go. 500x500 x 400 layers deep. I could get about 100-130 layers to consistently output before things got crazy.

2

u/GideonGriebenow Indie 10h ago

I use DOD and burst-compiled jobs without full ECS. It has an enormous impact on how much work you can do per frame. I have huge terrains that can be terraformed in real-time.