Search Unity

Official Hybrid Rendering package becomes Entities Graphics

Discussion in 'Graphics for ECS' started by arnaud-carre, Aug 17, 2022.

  1. arnaud-carre

    arnaud-carre

    Unity Technologies

    Joined:
    Jun 23, 2016
    Posts:
    97
    Hybrid Rendering package becomes Entities Graphics

    Entities Graphics
    The Entities Graphics package, previously known as Hybrid Renderer, provides systems and components for rendering ECS entities. It is a system that collects the necessary data to render ECS entities, and sends this data to Unity’s existing rendering architecture. With Entities Graphics, users can continue to use familiar workflows via Unity’s Scriptable Render Pipeline (SRP), including Universal Render Pipeline (URP) and High Definition Render Pipeline (HDRP), to author content and define rendering passes.

    Rationale to rename to Entities Graphics
    The hybrid rendering package “com.unity.rendering.hybrid” is now “com.unity.entities.graphics”, and the package will be referred to as “Entities Graphics” in the documentation.

    In ECS for Unity 2022, we decided to go for more consistent naming in some packages. In particular, we found that users were often confusing “com.unity.rendering.hybrid” as an additional rendering pipeline, which was not true. Additionally, the name is more consistent because “com.unity.entities.graphics” contains code to draw what the “com.unity.entities” package produces.

    How?
    In ECS for Unity 2022, “com.unity.rendering.hybrid” still exists but is an almost empty package. It just contains a dependency on the new “com.unity.entities.graphics” package. So if you open your project, “com.unity.entities.graphics” will be downloaded automatically, and you don’t have to do anything. Just know that “com.unity.entities.graphics” contains the code to draw entities. “com.unity.rendering.hybrid” is now just an empty package to ensure a smooth transition.

    Do I need to refactor my code?
    If your project previously used “com.unity.rendering.hybrid”, you don’t have anything to change in your code.

    You may have to rename some classes if you are using some hybrid rendering classes or structs in your own custom code. As a rule of thumb, any “Hybrid” in class/struct/enum has been replaced with “EntitiesGraphics”. For instance “UpdateOldHybridChunksJob” is now “UpdateOldEntitiesGraphicsChunksJob”

    Future Plans
    Moving forward, the “com.unity.rendering.hybrid” package will be completely removed. Only “com.unity.entities.graphics” will remain. We strongly encourage you to add the “com.unity.entities.graphics” package to your project during the transition period via the package manager or directly modifying the manifest.json. Doing this will prevent you from getting some errors about missing code when the old “com.unity.rendering.hybrid” will be completely removed.

    Existing Platform Gaps
    The Entities Graphics package currently does not support WebGL due to the lack of compute shader support on WebGL. Since WebGPU will support compute shaders, we are currently exploring WebGPU platform support, and Entities Graphics compatibility after. For users looking to use the Entities package and build towards WebGL, users will need to bridge ECS data to GameObjects, and render GameObjects to WebGL. We are planning to provide users with samples and documentation on how this can be achieved in future releases.

    BatchRendererGroup API
    You may have heard about BatchRendererGroup (BRG). BRG is an API for high-performance custom rendering in projects that use SRP and the SRP Batcher. BRG is the perfect tool to:

    • Render ECS-based entities.
    • Render a large number of environment objects where using individual GameObjects would be too resource-intensive.
    • Render custom terrain patches.
    Currently, the Entities Graphics package culls all the entities in a scene and generates the right Draw Commands for the frame using BRG. The package also uses ECS-based fast chunk state change mechanism to upload the minimum amount of GPU data per frame properly. Useful to note, BRG can be used independently of Entities Graphics, to achieve high-performance custom rendering.

    We look forward to hearing about your experience of working with Entities Graphics and BRG.
     
    Thaina, JohngUK, saskenergy and 17 others like this.
  2. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    306
    Will Entity Graphics in DOTS 1.0 support drawing of 2D sprite renderers without using a companion game object?
     
    FoodFish_, mahdi_jeddi and ThatDan123 like this.
  3. GameFinder

    GameFinder

    Joined:
    Jan 7, 2015
    Posts:
    17
    I recommend removing “com.unity.rendering.hybrid” package directly. Not only saves time but also less confusing in the future.
     
    KarelA, Occuros, Sylmerria and 3 others like this.
  4. Holyren

    Holyren

    Joined:
    Jul 8, 2017
    Posts:
    35
    With the soon to be removed convert to entity, how are we supposed to utilize HYBRID_ENTITIES_CAMERA_CONVERSION?

    I have been trying to use Baking, but I have not been able to make it work. Looking at samples, all of them have static cameras.
     
    instriker_911 likes this.
  5. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    122
    Can it be, that the MaterialProperty attribute has been changed without notice? the MaterialPropertyFormat did not exist anymore and is replaced by an gpu overwrite integer. The manual still reference that format.

    [MaterialProperty("NAME", MaterialPropertyFormat.Float3)]
     
    Elapotp likes this.
  6. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Yes, the MaterialProperty attribute no longer has a format enum, Entities Graphics just uses the size of the type. That enum only had meaning for HRv1, and has in practice has been unused for a long time.
     
    StefanWo and Arnold_2013 like this.
  7. Elapotp

    Elapotp

    Joined:
    May 14, 2014
    Posts:
    98
    Did I get it right, that right now we had to type it like that?:
    Code (CSharp):
    1. [MaterialProperty("NAME", sizeof(float3)]
     
  8. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    No, nowadays you only have to type
    [MaterialProperty("NAME")]
    . The second integer is used for actually overriding the size to be something else, but I don't think that parameter is really useful, that feature is only used internally for optimizing transform matrix size on the GPU.
     
    charleshendry and Elapotp like this.
  9. kite3h

    kite3h

    Joined:
    Aug 27, 2012
    Posts:
    196
    • Render a large number of environment objects where using individual GameObjects would be too resource-intensive.
    • Render custom terrain patches.

    In this case, the trend these days is not to do hierarchical culling with CPU, but rather meshlet culling through cone check with compute shader. Does this mean that culling compute shader is our own?
     
  10. mhernandez88

    mhernandez88

    Joined:
    Jul 20, 2016
    Posts:
    38
    It seems that Lights2D feature of URP is unsupported by entities.graphics, is this correct, if so can we expect support or is there an alternative way to bake Lights2D into entities.
     
  11. IsaacsUnity

    IsaacsUnity

    Unity Technologies

    Joined:
    Mar 1, 2022
    Posts:
    94
    Hello everyone, the pre-release of ECS for Unity is now available with Unity 2022.2 Tech Stream. More details over here!
     
    JussiKnuuttila and jivalenzuela like this.
  12. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    I am seeing an error when trying to add "com.unity.entities.graphics"


    Code (CSharp):
    1. [Package Manager Window] Cannot perform upm operation: Cannot find a version of package [com.unity.entities.graphics] compatible with this Unity version (2022.1.21f1). [NotFound].
    2. UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
     
  13. Fribur

    Fribur

    Joined:
    Jan 5, 2019
    Posts:
    136
    Error is correct, because Entities 1.0 only works with Editor >2022.2.0f1 (as per documentation)
     
    jessee03 likes this.
  14. swantonb

    swantonb

    Joined:
    Apr 10, 2018
    Posts:
    172
    dumb question, in order to use the batch render group I just have to place the game objects in a subscene, right? Besides this do i have to add in scripting define symbols "USE_BATCH_RENDER_GROUP" and "USE_HYBRID_RENDERER_V2" ? (sorry i forgot the exact names i mightve got them wrong)
     
  15. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    The Entities Graphics package always uses the BatchRendererGroup. If you use Entities 1.0, you don't need any scripting defines anymore, those were only used in early versions of the package.
     
  16. linfuqing

    linfuqing

    Joined:
    May 11, 2015
    Posts:
    166
    How can i implement a custom culling in Entities Graphics?
     
  17. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Currently there is no customization API for the culling, but all the code is included in the package. If you want to customize culling, you can modify the package source.
     
    mahdi_jeddi and linfuqing like this.
  18. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,264
  19. phreezie

    phreezie

    Joined:
    Oct 3, 2019
    Posts:
    119
    In v0.51, I was doing without the hybrid renderer by not destroying entities after conversion. It made it possible to use DXR.

    Is this still possible with v1.0? I see that now all GameObjects in my SubScene seem to be destroyed and thus not rendered if I don't add the Entities.Graphics package.
     
  20. userq

    userq

    Joined:
    Jun 4, 2017
    Posts:
    40
    Is this also working on mobile? The entities are shown in the edit play mode. But when I make a build on android, nothing is shown.
     
  21. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    The latest Entities Graphics package should work with Android. Can you see any error messages either when making the build, or in Android Logcat when running the build?
     
  22. userq

    userq

    Joined:
    Jun 4, 2017
    Posts:
    40
    Hi @JussiKnuuttila , sorry for the delay. I can confirm, it works on mobile, no errors.

    The issue was something with my code logic itself and mainly related to the order of things: for example a system for instantiating things was disabled before it got to instantiate them. However, in the editor the logic was different.
     
  23. FoodFish_

    FoodFish_

    Joined:
    May 3, 2018
    Posts:
    58
    Would also like to know this.
     
  24. zenbin3d

    zenbin3d

    Joined:
    Jul 7, 2023
    Posts:
    25
    Hey @JussiKnuuttila,

    Are there any plans to add static batching support to Entities Graphics?
    It's still the only easiest and cheapest way to bring draw calls down when rendering large static objects made up of different meshes that share the same material.
    Any chance for it to be added for Unity 2022?

    Thank you!
     
    apkdev likes this.