Hybrid Rendering package becomes Entities Graphics

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.

21 Likes

Will Entity Graphics in DOTS 1.0 support drawing of 2D sprite renderers without using a companion game object?

3 Likes

I recommend removing “com.unity.rendering.hybrid” package directly. Not only saves time but also less confusing in the future.

6 Likes

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.

1 Like

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)]

1 Like

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.

2 Likes

Did I get it right, that right now we had to type it like that?:

[MaterialProperty("NAME", sizeof(float3)]

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.

2 Likes
  • 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?

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.

Hello everyone, the pre-release of ECS for Unity is now available with Unity 2022.2 Tech Stream. More details over here !

2 Likes

I am seeing an error when trying to add “com.unity.entities.graphics”

[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].
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

Error is correct, because Entities 1.0 only works with Editor >2022.2.0f1 (as per documentation)

1 Like

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)

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.

How can i implement a custom culling in Entities Graphics?

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.

2 Likes

I have an example of doing this using asmref and replacement systems. Be warned, it is pretty involved. My use case is that I wanted to do skinning after culling and LODs to save resources. Latios-Framework/Kinemation/Systems/LatiosEntitiesGraphicsSystem.cs at v0.6.4 · Dreaming381/Latios-Framework · GitHub

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.

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.