Search Unity

Will using HR2 in non-dots project help with rendering performance?

Discussion in 'Graphics for ECS' started by mailfromthewilds, Sep 27, 2021.

  1. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    217
    Am wondering

    Am not using DOTS currently but am wondering if game could make use of HR2 for rendering performance
     
    hippocoder likes this.
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Hybrid Renderer is the rendering system for DOTS. If you want to make use of it, you have to use DOTS for the parts that you want to render with it.

    If your game is otherwise non-DOTS, this would probably be the easiest to do for things like static background objects and such, which you could place into subscenes so they get converted into DOTS entities.
     
    hippocoder and apkdev like this.
  3. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    217
    well yeah thats what ive been talking about, static stuff like trees or terrain

    but my question still stands, is it actually going to improve rendering performance over standard builtin renderer?
     
  4. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Rendering performance will strongly depend on the type of content, and how well it batches.

    HRV2 is the fastest in the case where there are many objects which have the same Mesh and Material, which can be rendered with large instanced draw calls. In this situation HRV2 should be a lot faster on the CPU than using GameObject based rendering.

    In the worst case, if everything has a unique Mesh or Material and there are no batching opportunities, we have usually seen that HRV2 rendering performance is roughly equal to GameObject based rendering. In this situation it is likely to consume more memory, as the DOTS chunk fragmentation is likely to be high and a lot of memory is wasted.

    On the GPU, HRV2 rendering should usually be approximately the same speed as GameObject rendering, but that is likely to be both hardware and content dependent.
     
    apkdev likes this.
  5. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    @JussiKnuuttila I believe currently it's caused by Mesh or Material is using IShareComponentData. Long time ago I heard there is plan to migrate it to IComponentData. Do u have any timeline when it will happen?
     
  6. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    What about same mesh but different submeshes? Like Static batching work?
     
  7. apkdev

    apkdev

    Joined:
    Dec 12, 2015
    Posts:
    284
    Thank you for this summary, this clears up a lot of my confusion as well.

    I'd like to add that if you're GPU bound, the lack of occlusion culling in HRv2 could result in lower performance (because you'll be rendering a lot of unnecessary objects). This largely depends on your scene geometry, your camera perspective, etc. My game is suffering from this currently so I hope development of the HRv2 occlusion culling system is proceeding well.
     
  8. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    In HRV2, a different submesh will behave the same as a different mesh, so it will break the batch.
     
    apkdev likes this.
  9. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    May be this is not place for question but.

    Do Unity have plans to fix this for HRV2 or HRV3 whatever?
     
  10. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    We are working on improvements, but unfortunately I can't share details about them right now.
     
    JesOb, optimise and apkdev like this.
  11. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Been a while since I've used HR and I have a related question. This is in HDRP FYI.

    We have a use case where we have up to 200 unique meshes, currently rendered with DrawMesh. Same material. And when meshes go in and out of the frustum there is a significant main thread cpu hit up to 2ms depending on number entering/leaving culling planes. It's significantly more then what the most naive frustum culling would cause so assuming there is something else being updated that causes the bulk of this.

    So the question is does HR bypass whatever that cost is? If you have some idea of what it even is.
     
  12. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Did I understand correctly, that this cost is only observed when the objects initially enter or leave the frustum, but is not seen while they stay inside and keep rendering each frame? Such a cost is definitely unexpected. Would you be able to share some Unity Profiler captures, where this unexpected spike is seen, and a comparison frame which is otherwise similar but is missing the spike?

    Hybrid Renderer does use a different rendering code path compared to DrawMesh, so it's possible it is not affected by this issue, but I'm unable to confirm this without understanding what causes the original performance cost.
     
  13. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    So profiling showed all the time as being in the editor loop. Seems sort of strange but if that's accurate then no big deal.
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    @JussiKnuuttila

    I'm rather interested in using HR2 for my static scenes and wondered if Unity would be kind enough to throw together a scene or quick guide to help us who are otherwise using gameobject pattern (monobehaviours etc) but want more performance, particularly open world rendering - all these elements would be static, but still need to be rendered quickly.

    I don't know what the best way would be to go about mixing things like this. I am on URP 12 at the moment. I think such a thing would help a great number of Unity customers who want more performance for static things and aren't able to work with ECS/DOTS in general.

    Any help here would be great. Perhaps it could even be a blog post or even a bit more info for people wanting a hybrid approach to their gameobject games.
     
  15. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Hello!

    We are working on some features which are intended to help with speeding up parts of GameObject based projects using the same technology as the Hybrid Renderer is using, including a much improved version of the BatchRendererGroup API. When that tech is ready, we will have samples and documentation for it.

    If you are looking for something you can use immediately, then using Hybrid Renderer with the ECS should be the easiest way to go.

    The simplest approach would be to place some of your static GameObjects into subscenes, which will then be converted into DOTS Entities and rendered using Hybrid Renderer. This process removes the original GameObjects, so there could be issues with things like game logic scripts or collisions. However, if the objects are purely visual, then this is likely fine. Alternatively, you could manually create rendering Entities using the RenderMeshUtility.AddComponents API, while leaving the GameObjects in place with disabled Renderers.
     
    mariandev, apkdev and hippocoder like this.
  16. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thanks. That sounds brilliant and just what I need. If it's going to drop within 2022.1 then I would be more than happy to wait!