hello, i am currently find and watching amazing tutorials one 2D DOTS/ECS (using actual quad texture mesh gpu instance rendering with custom shaders not built in sprite rendering):
currently i wish to test limits of 2D sprite rendering in unity but it is difficult for me to find the best current up to date ways for implementation in this (2021).
does anyone know step by step how besides documents such as:
this asset developer has good tutorial for setting up raw working station project for ECS DOTS, but i am having difficult times searching for best 2D workflow set up… is only way for using ECS DOTS 2D, mesh renderer and custom shader? i read project tiny is not up to date for now, makes me sad.
I don’t think there is a clear 2D workflow yet. Hybridrenderer still seems really bad for sprites (creates a sprite hybridcomponent with an invisible Companion GameObject AFAIK). I really think it depends on how much time you want to spend on this. Either you do it all yourself specific to your needs or you go the hybrid route and wait until someone else creates something useful.
I decided to go the Hybrid route (with some adjustments) because its just good enough for my usecase right now.
If you want to draw hundreds of thousands of sprites you probably should implement your own solution.
I would consider animating manually for right now. Code Monkey does have a DOTs sprite sheet animation video that is pretty good for the basics. I wouldn’t use Graphics.DrawMesh though.
If you have a sprite atlas, you can create a property in your shader to move through the sprites in the sheet (pretty standard stuff). Then, you can use custom material property overrides to animate the selection of sprites. That is what I did for this little test here:
More details about the general method in this thread:
Thanks. It is actually pretty basic. If you check out the other information I posted, you will see it is very easy to implement. Here is also a video on Material Properties that might be helpful.
I’m on the fence between 3D and 2D with my current project. If I go 2D, I’ll flesh this out more and post additional details.
Is this technique only for use with DOTS/ECS/Hybrid renderer? I was looking into more efficient means for rendering sprites in standard Unity environment.
afaik non of the solutions there is really maintained and the reason is that they are stress tests / very specific use cases. Non of them really depend on dots but they heavily benefit from ecs (data layout / iteration) jobs (parallel processing) and burst / math (sind, speed) + better graphic api (native containers / buffer access).
I think you have 3-4 solutions in the thread. At the time I considered the one I put there the simplest and most performant (except I kept it general and you can squeeze out more by pushing some calculations like ltw to the gpu and limit it to 2d) —those all do not have culling though or other hybrid renderer functionality - they simply rely on drawmeshinstancedindirect ie good to render much of the same
not sure if there are now more performant ways / better implementations….