Search Unity

CreateMissingRenderBoundsFromMeshRenderer Removed in Hybrid Renderer 0.3.4

Discussion in 'Graphics for ECS' started by alfiare, Feb 19, 2020.

  1. alfiare

    alfiare

    Joined:
    Feb 10, 2017
    Posts:
    30
    I updated to the Hybrid Render 0.3.4 along with the rest of the DOTS related packages and it looks like the CreateMissingRenderBoundsFromMeshRenderer system got removed, this seems to be why all the entities I have stopped being rendered. I'm creating all my entities in Code, not from GameObjects or Prefabs being converted. I looked through the packages and the only place I can see RenderBounds being created now is in MeshRendererConversion.cs.

    Do I now need to be creating RenderBounds on any code created entities that want to render?

    This works fine if I revert back to the Hybrid Renderer 0.3.3 and the CreateMissingRenderBoundsFromMeshRenderer system is back.
     
    Last edited: Feb 19, 2020
    charleshendry likes this.
  2. TLRMatthew

    TLRMatthew

    Joined:
    Apr 10, 2019
    Posts:
    65
    I found the same thing while updating my project the other day. For now I've added RenderBounds manually when I add the RenderMesh component, using
    mesh.bounds.ToAABB()
    . I was going to make a post about it, but I came to the conclusion that they're assuming/encouraging everyone to be using GameObjectConversion now, and it won't be too hard for me to move to that too when I get around to it.

    However it would be nice if the changelog for the package included details like this...
     
    mkracik, ivlasiuk and meanmonkey like this.
  3. alfiare

    alfiare

    Joined:
    Feb 10, 2017
    Posts:
    30
    Yeah it's just annoying, mesh.bounds can only really be touched from the main thread, I have a whole lot of creation of rendered entities that goes on inside jobs. I may end up just creating my own version of CreateMissingRenderBoundsFromMeshRenderer just because with everything I'm doing being dynamic creation I don't have a use really for GameObjectConversion.
     
  4. meanmonkey

    meanmonkey

    Joined:
    Nov 13, 2014
    Posts:
    148
    same here, just updated to hybrid renderer to 0.3.4 and it's not rendering at all. Is this behaviour intended or can we expect a fix for this ?

    EDIT: I could fix it by adding the RenderBounds component and assigned the mesh bounds via .ToAABB() Thx for the hint @LastResortMatthew
     
    Last edited: Feb 20, 2020
  5. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Talk about no love for this package, cant' even be bothered to create release notes for breaking changes.
     
  6. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    If you instantiate prefabs, the RenderBounds (and ChunkWorldRenderBounds) will be added automatically to the prefab. Everything works as usual in this common case. But if you create entities from scratch in the code, you need to manually add RenderBounds yourself now.

    This change was made to improve the runtime performance of the bounds system, and to solve fragmentation issues when instantiating entities at runtime. Previously if you instantiated one new entity every frame, you ended up with chunks of 1 entity each. Now the new entities get properly added to the same chunks as existing entities (as their archetype matches).

    We are sorry that this breaking change slipped though the change list. Our current entity instantiation test is instantiating prefabs instead of manually crafting entity in code. We will add a new test case that covers this use case too.
     
    alfiare, TLRMatthew and meanmonkey like this.
  7. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    We now have a dedicated team responsible for hybrid.renderer package. Our team has been doing a big refactoring to the hybrid renderer. We internally call it "Hybrid Renderer V2". This new version adds missing features, fixes bugs and improves performance. It also has proper test coverage to ensure that features don't break. Expect to see significant changes and continuous improvements to this package in the future.
     
  8. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    FYI a real pain with the hybrid renderer, and actually a persistent issue throughout almost all feature level DOTS packages, has been the inability to easily order where they run. In a real game completing jobs in the rendering group that can have dependencies from simulation is pretty much a non starter. And the only fixes are less then desirable. Custom player loops which in this scenario get a bit complex, and you have to reason about where ECS internals are plugging into them also to time it right. Or create dev versions of the packages.

    Once your scenario is using the bulk of feature level packages this actually gets extremely complex. I think what would probably help a lot is abstract out group creation and wrap it with a settings object of some type. So we can easily override what groups packages run in. Packages ordering their own systems via each other is fine, but pretty much everything else in a real game you end up wanting fine grained control over, and there really isn't a good reason to have that internal.
     
  9. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Is that URP support optimised for mobile in development too?
     
  10. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Yes. Hybrid Renderer V2 already has better URP support than the old hybrid renderer. In 2020.1 we focused on stable URP with minimal feature set and good CPU performance and test coverage. The flickering issues, random color issues and exploding polygons are gone. The missing lighting features will not land yet in 2020.1. We have a new backend that allows us to build those features in a robust and efficient way, making it possible to make quick progress for getting Hybrid URP feature complete.
     
  11. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    As you said this is a general DOTS architecture issue, not a renderer issue. I agree with you, better configurability would be great. Personally I would also like to have the rendering running fully separately from the DOTS main loop. DOTS main loop code would update rendering data and then rendering would run in a separate world in a separate timeline, allowing it to overlap with the next frame to achieve better parallelism and better CPU utilization.
     
    fnuecke, Dragnipurake97 and siggigg like this.
  12. ivlasiuk

    ivlasiuk

    Joined:
    Jul 21, 2013
    Posts:
    7
    So I need to add RenderBounds during entity cretion? Docs says that if we provide RenderMesh and LocalToWorld object will be rendered. But if to use only these two components - its not renderd
     
  13. ivlasiuk

    ivlasiuk

    Joined:
    Jul 21, 2013
    Posts:
    7
    I was able to add entity programmatically if to manually configure RenderBound via values form Mesh.bounds
    Code (CSharp):
    1.  
    2.        Entity leaderEntity = entityManager.CreateEntity(
    3.             typeof(RenderMesh),
    4.             typeof(Translation),
    5.             typeof(LocalToWorld),
    6.             typeof(RenderBounds)
    7.              );
    8.  
    9.         entityManager.SetSharedComponentData(leaderEntity, new RenderMesh
    10.         {
    11.             mesh = ourMesh,
    12.             material = ourMaterial,
    13.         });
    14.            
    15.         entityManager.SetComponentData(leaderEntity, new RenderBounds(){
    16.             Value = new AABB()
    17.             {
    18.                 Center = new float3(ourMesh.bounds.center.x, ourMesh.bounds.center.y, ourMesh.bounds.center.z),
    19.                 Extents = new float3(ourMesh.bounds.extents.x, ourMesh.bounds.extents.y, ourMesh.bounds.extents.z)
    20.             }
    21.         });
    22.  
     
    tallyho_stu and mkracik like this.
  14. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Correct. The document is outdated. Could you link me to the document with incorrect information so I can make sure we update that. Thank you!
     
  15. ivlasiuk

    ivlasiuk

    Joined:
    Jul 21, 2013
    Posts:
    7
    https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.3/manual/index.html

    This one.
     
    Last edited: Feb 25, 2020
    SebastianAaltonen likes this.
  16. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    Do you have an approximation of when the Hybred Renderer v2 will be released?
    Also does the Hybred Renderer v2 will implement the occlusion culling and dynamic batching ?
     
    Roycon likes this.
  17. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    We have DOTS occlusion culling technology also in development. Hybrid renderer doesn't need the old dynamic batching technique, the batching solution we use in hybrid renderer is superior to dynamic batching, and we improved the batching performance in Hybrid Renderer V2. You will see larger batch sizes and GPU performance improvements in scenes with larger batch sizes. The main goal however was to improve the CPU performance of the original hybrid renderer. Current profiling results are highly positive.

    I will give you release time estimate in the following weeks.
     
    andywatts, charleshendry and Opeth001 like this.
  18. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    does this means less Draw Calls or a totally different Technology ?
     
  19. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Hybrid renderer is batching by material/mesh and using large instanced draw calls. Each instanced draw can draw up to 1023 entities in Hybrid V2. The limit was around 400 in Hybrid V1. Traditional GameObject rendering is completely different. HDRP and URP GameObject rendering issues one draw call per GameObject. That's a huge difference.

    With GameObjects you could use static batching and dynamic batching to reduce the number of draw calls by combining meshes, but both static/dynamic batching costs significant amount of memory, and dynamic batching costs a lot of CPU time too as it combines mesh vertices at runtime on CPU. The new technology is definitely faster than either.
     
    mkracik, charleshendry and Opeth001 like this.
  20. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Updated hybrid.renderer documentation page. Lots of new info there, including fix for this. Also change log was updated with this breaking change. Both should land in next hybrid.renderer package.
     
  21. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    hey @SebastianAaltonen,
    i have a question about the Frustum Culling used in the Hybred Renderer Package.
    im trying to play with ECS stuff and create my own Hybred Renderer based on Graphics.DrawMeshInstanced.
    i saw the Intersect* functions inside the FrustumPlanes struct but i dont see any Intersect function taking a planes mask as parameter.
    generally there is some cases where some planes can be ignored like when the ChunkWorldRenderBounds is partially included in the frustum culling planes so all Entities within that chunk should compute Intersection only with interseting/out planes.
    do you guys use another way to calculate Frustum Culling or other Intersect functions are implemented in other parts?
     
    Last edited: Mar 10, 2020
  22. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Awesome. Btw I heard there is plan to develop full pure DOTS renderer. Is that Hybrid Renderer the first step to slowly getting there?
     
    Opeth001 likes this.
  23. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    There's no concrete plans for pure DOTS renderer yet for high end. Tiny exists for low end. We have done some DOTS pure rendering prototyping at Hackweek, and results look promising, but it would take years of development time to replace UnityEngine render backends, URP and HDRP completely. This is not something we are focusing to do right now. Instead we plan to improve hybrid renderer URP and HDRP support, to allow developers and artists to adapt DOTS ECS with minimal pain in their current GameObject + URP/HDRP based projects. DOTS is a huge performance increase and Hybrid Renderer V2 provides significantly better performance than Hybrid Renderer V1, which already provided much better performance than GameObjects.
     
    optimise likes this.
  24. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    UnityEngine render backends do you mean the C++ graphics part of Unity core engine?
     
  25. Studiomaurer

    Studiomaurer

    Joined:
    Sep 5, 2012
    Posts:
    56
    @SebastianAaltonen I really appreciate the efforts to optimize performance, you're doing a great job. But in my case, some ojects seem to be culled while still on screen (I presume their Chunkrenderbounds are not correct ??). I have tons of performance left, is there a tag or some other way to exclude those specirfic entities from culling?
     
  26. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    There is no tag to completely disable culling, there is only PerInstanceCullingTag to control whether individual entities get culled, or whether just the chunk containing them is culled (much faster, but also much coarser, so more entities will get drawn).

    ChunkWorldRenderBounds should get updated automatically to the correct value, as long as RenderBounds is set correctly on each entity (normally set to the Mesh bounds). RenderBounds gets automatically updated to WorldRenderBounds, which then gets automatically updated to ChunkWorldRenderBounds.
     
  27. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,267
    Just as a heads up, I don't think this works correctly when changing a chunk's archetype in place by removing either a Disabled component or a Prefab component. That action doesn't affect change nor order versions yet the system doesn't operate on chunks with Disabled or Prefab components causing the chunk bounds to go stale undetected.
     
  28. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    This definitely sounds like a bug, would it be possible for you to submit a bug report about it?
     
  29. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,267
    Unfortunately, I don't have a project to reproduce it. This is just a pitfall I have run into when working with chunk components and from reading the RenderBoundsUpdateSystem code, it seems like it may be hitting the same pitfall since it uses change and order filters to keep a chunk component cache up-to-date but does not include prefab and disabled components in the query.