Unity DOTS / Entities vs GPU Instancing

This is more of a general advice question.

I want to make procedurally spawn interactive grass (and bushes en trees in the future). In my case, I want the grass to react dynamically to wind, fire, ground displacement, displacement from moving objects etc. I was wondering, with DOTS 1.0 now being out, is there any merit in using Entities to handle grass and/or other vegetation instead of GPU instancing and the standard GameObjects. What are possible drawbacks of using one over the other?

Could maybe a combination of the 2 techniques be the best?

Entities are not magic, unfortunately. An Entity is a slim version of GameObject, basically. Also (at the time Im writing this) always quarter-broken & obsolete in few months, missing half the features gameObjects has and much harder to work with.

Burst compiler and the Job System, on the other hand, are the real magic. Why? Because they solve 2 real issues every programmer has:

  1. How to make my CPU code fast
  2. How to make my CPU code executed on multiple cores

And you can use them with GameObjects just fine (schedule burst-compiled jobs, that is).

_

Entities can help you if your game has hundreds to few thousands of GameObjects moving all the time AND their meshes do not change (because entities has nothing to do with meshes, it is just not the problem they solve).

Once your game hits, lets say, >10k of gameobject count - then even this shiny ecs will start to slow down your CPU far too much. How do I know that? Because I tried to create an entity-based line renderer for dots and these were my experimentally-derrived conclusions. After which I realized the GPU is the solution to handle thousands of objects at 60 fps, not entities.

_

I want the grass to react dynamically to wind, fire, ground displacement, displacement from moving objects etc.

Lets start with stating that your computer is 2 computers, really. One of them is your CPU and the other is the GPU:

  • CPU is universal and fast at doing few things at the time, this is why it is often given command-center roles
  • GPU is super fast at doing a LOT of small things, this is why it is often delegated to graphics
  • CPU and GPU communicate RARELY (few times/frame)

The entire DOTS is CPU-only. But some things are better suited for GPU. This means that dots won’t help you with everything. For example: dots won’t help you with procedural or animated meshes. Why? Because both calculating and sending to GPU a new mesh data every frame is a bad idea (performance-wise). You can manage sending SOME data to GPU every frame, but not re-sending ALL the data.

TL;DR: wind, fire, ground displacement and displacement from moving objects are type of work that is best suited for GPU. Why? Because it is best at vertex-related calculations AND this will minimize amount of data that must to be exchanged between CPU and GPU.

GPU instancing and the standard GameObjects

You can use GPU instancing without GameObjects, just keep Matrix4x4 ( Transform-equivalent) for each mesh.