Search Unity

Questions about BatchRendererGroup

Discussion in 'Graphics for ECS' started by DDKH, Apr 5, 2021.

  1. DDKH

    DDKH

    Joined:
    Jun 13, 2013
    Posts:
    25
    Hi!

    How to perform batched draw calls using BatchRendererGroup?
    Currently i'm adding batches per each chunk, and setting its matrices from LocalToWorld. Rendering is fine, but batching is not working at all - i'm getting the same amount of draw calls as count of the mesh instances.

    SRP batcher is Off
    Hybrid renderer package is not added

    @SebastianAaltonen
    @JussiKnuuttila
     
  2. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    BatchRendererGroup API is a low level API designed for hybrid.renderer use. You need to have SRP Batcher active to use this API, it doesn't work without SRP Batcher.

    If you want to use this API manually without DOTS, you need to write your own renderer, similar to the hybrid.renderer. Minimal implementation will require couple of thousands of lines of low level code, and deep understanding of the Unity's shader system. More info here: https://docs.unity3d.com/Packages/c...rid@0.11/manual/batch-renderer-group-api.html
     
  3. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    We are planning to heavily refactor the BatchRendererGroup API. Make it more user friendly and documented. This will however break backwards compatibility with the old API version. I would suggest waiting until we have landed this properly supported API version.
     
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,271
    I noticed you have been copying and pasting this response in a couple of threads. Do you perhaps have an estimated timeline for how long we have to wait for? Waiting indefinitely is rarely a good idea.
     
  5. DDKH

    DDKH

    Joined:
    Jun 13, 2013
    Posts:
    25
    Thanks for the answer!

    Hopefully the new API will be compatible to render on older mobile devices, at least GLES 3.0

    Just tried to run Hybrid Renderer v2 on my android test phone, no luck, it needs compute buffers(
    Regarding to the documentation, DOTS rendering team won't focus on mobile platforms in 2021, a bit frustrating for me :(

    So, would be great to have some simple solution that support render on older mobile devices (their market share is still valuable https://developer.android.com/about/dashboards/index.html)
    Or, at least, some low or mid-level tools to build our own renderer, because DOTS stack is performant by default which is perfect for low-end devices
     
  6. DDKH

    DDKH

    Joined:
    Jun 13, 2013
    Posts:
    25
    It is possible to write a stupid simple renderer system that draw static meshes like below:

    Code (CSharp):
    1. [UpdateInGroup(typeof(PresentationSystemGroup))]
    2. public class RendererSystem : SystemBase
    3. {
    4.     protected override void OnUpdate()
    5.     {
    6.         Entities
    7.             .WithoutBurst()
    8.             .ForEach((LocalToWorld l2w, SharedMesh sharedMesh, SharedMaterial sharedMaterial, MeshRendererData rendererData) =>
    9.             {
    10.                 Graphics.DrawMesh(sharedMesh.Value, l2w.Value, sharedMaterial.Value, 0, null, 0, null, rendererData.CastShadows, rendererData.ReceiveShadows, rendererData.UseLightProbes);
    11.             }).Run();
    12.     }
    13. }
    and it works surprisingly well enough with SRP enabled, even on old gles 3.0 device, and renders something like that: (warning! triple-A blockbuster screenshot)
    upload_2021-4-10_22-15-6.png

    But what to do with skeletal mesh renderers? Converting them manually is a super complex task :)
     
    Last edited: Apr 10, 2021
    MNNoxMortem and jdtec like this.