Search Unity

Question hello, what is most up to date methods to start with 2D and DOTS/ECS package?

Discussion in 'Entity Component System' started by graphicsayy97, Oct 5, 2021.

  1. graphicsayy97

    graphicsayy97

    Joined:
    Dec 24, 2020
    Posts:
    50
    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:

    https://philsa.github.io/rival-doc/tutorial.html

    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.
     
  2. MaNaRz

    MaNaRz

    Joined:
    Aug 24, 2017
    Posts:
    117
    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.
     
    graphicsayy97 and apkdev like this.
  3. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Search the forum, there a two threads where we tested limits, tiltle is “???k sprites” and “1M sprites” or so…some year or two back…
     
    graphicsayy97 likes this.
  4. DV_Gen

    DV_Gen

    Joined:
    May 22, 2021
    Posts:
    14
    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:
    https://twitter.com/_DV_Gen_/status/1442501356908990465?s=20

    More details about the general method in this thread:
    https://twitter.com/_DV_Gen_/status/1441855088243380224?s=20

    And docs here:
    https://docs.unity3d.com/Packages/c...ustom-shadergraph-material-property-overrides

    There is also an Entities 2D package, but I haven't looked into it yet: https://docs.unity3d.com/Packages/com.unity.2d.entities@0.22/manual/index.html
     
    varnon and the_unity_saga like this.
  5. graphicsayy97

    graphicsayy97

    Joined:
    Dec 24, 2020
    Posts:
    50
    ok thank you all i will make custom
     
  6. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    That is extremely impressive, the Samus Aran sprite renderer you designed.

    Are you willing to potentially sell this as an asset down the line?

    Have you considered making a public demo just to show the concept in tangible form for Unity as an asset package?

    I assume the technique pretty much boils down to efficient use of the GPU in rendering the image data?
     
  7. DV_Gen

    DV_Gen

    Joined:
    May 22, 2021
    Posts:
    14
    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.
     
    the_unity_saga and varnon like this.
  8. the_unity_saga

    the_unity_saga

    Joined:
    Sep 17, 2016
    Posts:
    268
    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.
     
  9. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Did you check the threads I mentioned?

    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….


    https://forum.unity.com/threads/200k-dynamic-animated-sprites-at-80fps.695809/