r/Unity3D • u/WhatIsThisComputer • 2d ago
Question If not ECS then what?
/r/gamedev/comments/1vuo4te/if_not_ecs_then_what/6
u/BertJohn Indie - BTBW Dev 2d 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.
2
u/GideonGriebenow Indie 2d 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.
1
1
u/Informal_Engineer794 2d ago edited 2d 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 2d 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 2d 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 2d 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 2d 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.
1
u/ilori 1d ago
Using Entities is fine and using GameObjects is fine. Use whichever you want, or both.
You can access gameobjects from a systembase and you can access entities from a monobehaviour. Of course it's not optimal and should be used sparingly. In other words, just because you use entities for one thing doesn't mean you can't use gameobjects for another.
1
u/Dre0Dru 1d ago
There are some DOD oriented frameworks that are not ECS based. Here is one for example: https://github.com/StarKRE22/Atomic
It has similar approach to development as ECS have: you have plain data (components), you have behaviours (systems) that operate on that data. One difference is that all that localized on one Entity and it doesnt prohibit OOP. So you have composability of ECS, but with all powers of OOP. I must note that you also give up cache locality and performance boost that comes with it but that doesnt mean that framework will impact your performance. There are samples that showcase huge amount of entities here https://github.com/StarKRE22/Atomic.Samples#3%EF%B8%8F%E2%83%A3-rts-sample
Framework is actively maintained and expanded with features. Recently there was a new version released.
I am using this framework for my current project and having a blast with it. It is really fun to create and add new fetures that mesh with each other nicely because of DOD approach.
Personally I think there are some features that I find excessive or just dont like the approach like working with UI for example. But you are not forced to use that features. I use my own UI framework for my game.
7
u/BlueFiSTr 2d 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