Search Unity

Hybrid renderer

Discussion in 'Graphics for ECS' started by xVergilx, Jan 23, 2019.

  1. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Hybrid renderer package got available recently in package manager.

    Has anyone tried it out yet?
    Looking at code it seems really interesting, as I was thinking about re-writing some of my decal system into ECS.

    Got me some ideas on how to properly hook the systems to cameras and the Unity's API.
    Although, it got me thinking why the Graphics API instead of CommandBuffer?

    Also, it would be nice to see some benchmarks against default render system (but it might be too early in development for this).
     
    Last edited: Jan 23, 2019
  2. vitautart

    vitautart

    Joined:
    May 3, 2018
    Posts:
    29
    Well, new Hybrid renderer API for 2018.3 is mostly the same as it was in previous ecs packages, now it is just separated to its own package with some little refactoring. And yes it is fast for a lot of same meshes, because of default instancing.
    The most interesting part of it is Hybrid renderer API for 2019.1 that uses not Graphics API but totaly new BatchRendererGroup. In source code it is called RenderMeshSystemV2.

    https://docs.unity3d.com/2019.1/Documentation/ScriptReference/Rendering.BatchRendererGroup.html

    If you want do some low-level stuff with Hybrid renderer, I recommend you start thinking about Hybrid renderer with BatchRendererGroup API and not about Hybrid renderer with Graphics API, because I'm assuming that this API would be deprecated in a future.
     
    xVergilx likes this.
  3. Sashok9203

    Sashok9203

    Joined:
    Jun 3, 2018
    Posts:
    24
    How to use it?
    Examples?
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Attaching RenderMesh component + Position does the trick afaik.
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    There is no plan for deprecating it.

    The recommended approach is to simply use Entity + RenderMesh component + Position or LocalToWorld.

    We will be adding more features to it over time. Use Of BatchRendererGroup low-level API is an implementation detail and won't break anything in the normal usage. It will simply become faster.
     
    twobob, evanhu2003, FROS7 and 3 others like this.
  6. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    How far are we from being able to set colors via an IComponentData per Entity. I know it is possible today and there a few custom solutions out there...just curious if this is something you are working on at the moment or if it is a bit further out....
     
  7. learc83

    learc83

    Joined:
    Feb 28, 2018
    Posts:
    41
    One thing I noticed after upgrading to the new preview and switching to the new hybrid renderer, is that I was able to programmatically build meshes from within ECS code. Previously when I tried to construct a mesh I was getting warnings about the Vector arrays I was using to assign to mesh.vertices.

    I'm not sure if it was something to do with the hyrbrid renderer or no.
     
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    We're at the point in our game where we need to focus on how the levels are rendered. We're using a heck of a lot of prefabs for level geo instead of unique geo. Our game is not ECS based (yet) but does that mean we can still take advantage of superior static rendering performance wit this or is it for dynamic stuff?
     
  9. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    So, the 2019.1 alpha, they've changed the Mesh class, and can update the vertices a faster way? 'new preview and switching to the new hybrid renderer, is that I was able to programmatically build meshes from within ECS code' Did anything change with this particular mesh updating flow? I'm using Hybrid.MeshInstanceRenderer component simply to update meshes, while building my meshes inside another class using jobs. Is there a better way to build custom terrain mesh?
     
  10. js_bourdon

    js_bourdon

    Joined:
    Jul 10, 2018
    Posts:
    2
    I'm currently trying to combine the Hybrid Renderer with the Lightweight SRP. I managed to make it work, but quickly realized that baked lightmaps do not seem to be supported. Did I do anything wrong or is it indeed not supported. And if it's not, is it planned to be or that renderer is only intended to be used with the HD SRP with everything realtime?
     
    Last edited: Mar 28, 2019
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It is WIP, big time. It will support everything as far as I know but Unity has to make it to begin with.
     
  12. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    Is there a way to check if the entity is visible/invisible? Also, I wonder how to hide/show an entity. Is there any tag component for this?
     
    Alverik likes this.
  13. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
  14. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    I know that I can make renderer invisible if I set it's materials to zero length array, but I still wonder how to track the visibility of the entities. Gonna test if it is possible to set the entitie's material to null with no artifacts
     
    Opeth001 likes this.
  15. Deadcow_

    Deadcow_

    Joined:
    Mar 13, 2014
    Posts:
    135
    Is there a way to set material color per entity?
    I need something like in Boid example but with random boid colors. It feels really wrong to set unique shared component RenderMesh per entity... I'm just starting to dabble with ECS so sorry if it's too noobish question :)
     
  16. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    There's no MaterialPropertyBlock support in the hybrid renderer yet (yet means a year has passed since the release with such a vital feature missing).

    So using single shared material per shared data is a valid approach, although, sub-optimal.
     
    deus0 and Deadcow_ like this.
  17. Deadcow_

    Deadcow_

    Joined:
    Mar 13, 2014
    Posts:
    135
    Thanks. I read about manual rendering via Render class somewhere (maybe first ecs samples used this approach?).
    Do you know maybe, is there some way to use MaterialPropertyBlock with manual rendering?
    Or any other way to achieve this with ecs? Basically I need to spawn a few thousands spheres of different colors and sizes, how hard can it be
     
  18. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    There's no way around it w/o hacking hybrid render. Here's a link, someone posted a hacked version that should support material property block changes (I haven't tried it though).
    https://forum.unity.com/threads/materialpropertyblock-support-in-meshinstancerenderersystem.562369

    Alternatively, you can write your own render system, and hook it to the camera rendering via command buffer, or draw immediately via Graphics API.
     
    Deadcow_ likes this.
  19. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Silly question but how do I verify that my mesh is actually going through the hybrid render. It seemed too easy to setup. Something must be wrong
     
    Last edited: Sep 12, 2019
  20. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    It is :)

    You can disable the RenderMeshSystemV2 in
    the Entity Debugger which should make your meshes disappear.
     
  21. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    fantastic thanks
     
  22. sandstedt

    sandstedt

    Joined:
    May 24, 2015
    Posts:
    67
    And if it doesnt? :p Can't see any meshes that I have applied Convert To Entity script on (with Convert and Destroy on).

    EDIT: Haha, hadn't installed it o_O. Was looking in another open project.
     
    Last edited: Nov 20, 2019
  23. xuanyusong

    xuanyusong

    Joined:
    Apr 10, 2013
    Posts:
    49
    hi ~
    What's the difference between BatchRendererGroup.AddBatch and Graphics.DrawMeshInstanced ?

    such as srp batcher?

    https://blogs.unity3d.com/cn/2019/02/28/srp-batcher-speed-up-your-rendering/
     
    deus0 and Opeth001 like this.
  24. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    The biggest difference is that BatchRendererGroup requires you to manually do several things that are automatically taken care of otherwise. For example, when using BatchRendererGroup, you must provide your own culling logic using a C# callback. This can have a benefit in cases where you have very large amounts of identical or similar objects to render, but is generally much more difficult to use, and is only feasible for objects that share the same Mesh and Material.

    When SRP batcher is enabled, both of these rendering methods should render using SRP batcher, as long as the shader is SRP batcher compatible (which the Shader Inspector should tell you).
     
    deus0 likes this.