Search Unity

Official Hybrid Renderer V2 (0.4.0)

Discussion in 'Graphics for ECS' started by SebastianAaltonen, Mar 16, 2020.

Thread Status:
Not open for further replies.
  1. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Hybrid Renderer V2 MeshRendererConversion will setup various URP and HDRP specific components, such as previous frame matrices, inverse matrices, render layer data, etc. In V2, all of this data is stored in DOTS components. If you don't use the conversion system, you need to take a look at MeshRendererConversion.cs code, and do all of this setup yourself. And be prepared to change your entity building code frequently as we will be adding support for more URP/HDRP features requiring more components.

    Thus we highly recommend instantiating prefabs instead of building your own ECS entities from scratch in the code. Prefabs are the most optimal case for runtime performance as well as their archetype doesn't need to be changed (no extra structural changes). If you don't use prefabs, you might also see a bit more chunk fragmentation (and worse batching) in some corner cases.
     
    Last edited: Apr 16, 2020
    GDevTeam likes this.
  2. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    Is there also a possibility of a help class / method to create your own prefabs / archetype based on in the future? Like:
    Code (CSharp):
    1. RenderFactory.CreateArchetype(params Type[] customComponent);
    2. RenderFactory.CreatePrefab(params IDataComponent[] customComponentData);
    That might be helpful if the game have procedural content, so we would not have to constantly adapt your own code and would always be up to date.
     
    JesOb likes this.
  3. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    If you have procedural content, you could author a prefab just for rendering, and add all the procedural components to the entity you need after instantiating the prefab.

    We could also add public functions for setting up the archetype and correct component data for rendering, but be aware that these function signatures would change frequently, as we are adding support for more HDRP and URP features. More features need more input data.
     
    JakHussain likes this.
  4. l33t_P4j33t

    l33t_P4j33t

    Joined:
    Jul 29, 2019
    Posts:
    232
    is there any ETA for when lightmaps are going to be supported by the hybrid renderer v2?
    also hybrid render v2 is really laggy
     
    Last edited: Apr 16, 2020
  5. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    If you create good abstractions for conversion and keep them public, this won't really be an issue. Or at least it will minimize the pain. I've hit some built in conversion that was easy to work with, others where it was way too monolithic, it seems to be hit and miss. That and there is no good pattern for overriding built in conversion. Often you have to wholesale replace the conversion system, and then hope that the author didn't make the abstractions it does use (if any) internal.
     
  6. gnostici

    gnostici

    Joined:
    Jul 27, 2013
    Posts:
    23
    I thought I was wrong regarding my thread from yesterday and HDRP performance, but turns out that was half right. Problem is, it's hard to tell if this is a bug. @SebastianAaltonen , there are some screencaps attached to demonstrate the issue.

    A procedurally-generated quad is set as the mesh in a RenderMesh entity component, and (later) that entity is mass instantiated. The instances are put in another chunk (different components). With 2500 instances (plus the original), SRP batcher shows 2 quads (for the two chunks), so all is well. At 5000, I'd expect 2 quads. I see 20 vertices and 30 indices (five quads). At 6500, I see 24 vertices and 36 indices (6 quads). At 7000, the editor crashes with an error that the OS restarted the GPU (too much uploaded).

    There are two issues:

    1. The number of quads is unexpected. That's explained by your prefab advice. BUT!
    2. I wouldn't expect a high end GPU to hang with fewer than a dozen quads, but it does here.

    So, the question: Is this related to procedurally generating rather than using a prefab as you describe, or is this a bug I should report? Just want to be sure before I add to anyone's workload.

    2500 Instances (Frame Debugger and Entity Debugger): https://gyazo.com/bd6b2ceb2e8682cf593da7193d673cb8
    5000 Instances (Same debuggers) https://gyazo.com/cc1aa95b0c0ea079dfacca61c9944646
    6500 Instances (Likewise) https://gyazo.com/027f902770ce296fd6d71166c8a66f16

    Tomorrow I'll try this starting with a prefab, but in the meantime, I'm still learning. So, I'm a bit shy about calling something a bug without confirmation.

    Finally, suggestion:

    If issues are avoided just by using a prefab, why not have a method that just generates a prefab and puts it through the necessary paces behind the scenes, to automate all the same? It could take a mesh and material as input, and return a reference to an entity with the necessary components. It's a simple fix to use a prefab, but for developers who come along later, it could save some headache to have it fixed behind the scenes. Heck, we could write that ourselves, but it seems too simple while solving problems too complex for it to not be done already.
     
    Last edited: Apr 17, 2020
  7. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    792
    In an early version of ECS with buildin-renderer, i even displayed 300,000 instances of a Mesh on the screen at the same time at over 30fps. So 7000 should not be an problem.
     
    gnostici likes this.
  8. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Curious how the dev's think V2 culling would stack up against a partition based gpu culling scheme? Like Vegetation Studio uses for example.

    The one drawback of having large partitions like that for our use case is vegetation is dynamic. Rebuilding a partition is a noticeable framerate hit, and worst case we can have those hit once every few seconds. So a more granular system would be appealing. But it's a trade off, we can't take a significant constant perf hit or it's not worth it.
     
  9. gnostici

    gnostici

    Joined:
    Jul 27, 2013
    Posts:
    23
    If they're instantiated in batches of 2500, I can beat that.

    https://gyazo.com/e213f1fc43376187dc67535d5deb50d3


    The renderer checks for changes, and only uploads changed data to the GPU. That would explain it and be the end of it, except that I don't have to batch transform and rotation changes like that. And just going by the idea that too much is being sent in one draw call (still odd with so few quads), it should do the same thing when the quads are moved or rotated. On top of that, if I understand batch rendering, it shouldn't matter how many entities are being rendered (GPU side). Though it may slow things down CPU side (preparing the batch).

    Mind, that's just 500k + 1 quads all the same color, all pasted to the camera like a worldspace UI canvas. Then 500k of them are rotated behind the camera. AND in an actual UI, there would never be a need to do that. But this is still only 1 million tris. Plus, the 500k behind the camera should be culled. A whole bag of concern, but I'm trying to focus in on what seems to be closer to the root of it all.
     
    Last edited: Apr 17, 2020
  10. Zec_

    Zec_

    Joined:
    Feb 9, 2017
    Posts:
    148
    Hi @SebastianAaltonen! Your previous post here stated that we should wait until Hybrid Renderer 0.4.2. That version was just recently released, but according to the change log, only the dependencies were updated. Was that really the version you were talking about? Or did the expected version numbers change?
    https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.4/changelog/CHANGELOG.html
     
  11. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    962
    I'm also confused about the state of hybrid renderer but it seems to be working.
    I have latest entities 0.9, URP 9 and HR 0.4.2. - no errors and I can build - so I think it's fine.
     
  12. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    using HR 0.4.2, turning the V2 flag on, everything is still rendered on 0/0/0 ...
     
  13. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Do you see "Hybrid Renderer V2 active, MaterialProperty component type count X / Y" in the log?

    Did you delete your library folder after setting the define to project settings? There's a known issue with ShaderGraph shader invalidation. Old V1 shaders aren't compatible with V2. We have a fix for this problem. It will land in the next ShaderGraph preview package.

    Some more info here:
    https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.4/manual/index.html
     
  14. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Lightmap support is in the roadmap. Lightmaps require more work than most lighting features, as the whole lightmap baking process needs to be ported to DOTS. This is not just hybrid.renderer runtime work. The lightmap baker needs to understand DOTS scenes.

    What do you mean by "laggy"? We have seen performance increase in editor and standalone builds. I would like to understand where do you see performance downgrade? Editor/standalone, do you have debug features enabled, is burst compiler enabled in settings? Disabled burst compiler has huge effect on performance.
     
  15. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Are you using Shader Graph? If so, try reimporting your shader graphs (right click, Reimport) after enabling V2. We have made a fix that does this automatically in an upcoming version, but the currently released version unfortunately doesn't do it automatically.
     
  16. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    Just some random results I did testing on a large scene if anyone was interested (all safety checks off)



    Machine is a bit wonky, 3900x but a 1600 GTX, usually pretty GPU capped.

    Not really sure why tris/verts are so much higher in HRv2 but performance is good
     
  17. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Are you using Hybrid Renderer V1 or V2?

    Having 7000 entities shouldn't be a problem at all. I don't understand your setup at all. Why is SRP Batcher showing one quad for each chunk? Where do you get this "too much uploaded" error? Please file a bug report with minimal repro project attached. That would allow us to investigate this issue.

    We could add a method that creates all the required rendering components to an EntityCommandBuffer. You would pass in UnityEngine.Transform, UnityEngine.MeshFilter and UnityEngine.MeshRenderer and various parameters (we usually take from the GameObject). We could also accept UnityEngine.Material and UnityEngine.Mesh, but in that case we need a lot more input parameters, which will change once we add more URP/HDRP features in the future. Instantiating a prefab is still a bit faster, as prefabs are preprocessed in memory, and instantiation can simply copy this data very efficiently.
     
  18. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Thanks! Hybrid V2 is mostly a CPU optimization, so you can't see big gains in GPU limited scenarios. If you want to see big gains, I would suggest using more objects, but lower polygon count mesh on each. Good LODs are very important for rendering big mass of objects efficiently. Otherwise you become GPU bound very fast.

    How many objects/entities in the scene? Is this standalone or editor?

    Those tris/verts counters seem odd. If this is identical scene for all, then we need to investigate what's wrong with those counters. They should be identical in all cases. It's also strange that Hybrid Renderer V1 is 4x slower than URP. I have never seen results like this before. Could you post screenshots of the profiler so that we can see where the time is spent on CPU side?
     
    Last edited: Apr 17, 2020
  19. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    in editor but all safeties debugging off
    ~8800 render meshes. it's a small low poly city simulation.
    no lods or any optimizations.
    was really just a curious test of an asset i had on hand.

    should definitely do it in a build, but i was mostly just doing some quick testing.
     
  20. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    -edit-

    correction, trying to figure out why default was slower than hdrp, turns out for some reason default scene had a second directional light. results updated

    -endedit-

    Same scene with HDRP because I was curious

    upload_2020-4-18_9-44-43.png

    original to compare

    upload_2020-4-18_8-56-0.png

    upload_2020-4-18_9-43-45.png

    Empty project except scene with a bunch of renderers.
    Everything using defaults.
    No optimization.
    All safety turned off.
    Results from editor not runtime so take it with a grain of salt
     
    Last edited: Apr 18, 2020
    florianhanke likes this.
  21. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    This sounds like a very interesting repro case. If you could file a bug with the project folder and report case number here that would be great. The increase in tris / vertices is for sure not intended...
     
  22. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    I thought this was already in version 0.4.2 :)

    The problem i have is still the old one: My "terrain" is completly black and my camera goes black the moment my terrain goes into camera view. I need to enable "Stop Nans" on camera to see anything, but them the terrain is just black and everything else is displayed differently. If i dont create the terrain, then everything is displayed correctly so it looks like the error is inside this shader. I attached a screenshot of the shader, maybe you can help me here

    PS: And it looks like Amplify shader doesnt work with the new V2 renderer (still everything is displayed on 0/0/0), but this is not your problem i guess.
     

    Attached Files:

  23. Fribur

    Fribur

    Joined:
    Jan 5, 2019
    Posts:
    136
    I also had the issue that procedurally generated RenderMeshes where black, until I manually added all the additional components that Hybrid Renderer V2 MeshRendererConversion.cs would automatically add to Prefabs. Do your black entities have those new components?
    • WorldToLocal
    • PerInstanceCullingTag
    • BuiltinMaterialPropertyUnity_RenderingLayer
    • BuiltinMaterialPropertyUnity_WorldTransformParams
    • BuiltinMaterialPropertyUnity_LightData
    There are more, conditionally setup and initialized. See MeshRendererConversion.cs for details.

    Also, I think the automatic re-importing of ShaderGraph upon selecting Hybrid Renderer V2 is a fix in the ShaderGraph package (> 9.0.0 preview14?), and not in the Hybrid Renderer package.
     
    Last edited: Apr 18, 2020
    Samsle and florianhanke like this.
  24. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    I create my prefabs "correctly" according to 0.4.2, but only when enabling V2 via flag it gets dark. So what am i missing for components?
     
  25. OldMage

    OldMage

    Joined:
    Jun 25, 2018
    Posts:
    10
    I just wanted to voice my hope for using URP Lit Sprites with the hybrid renderer as well. Is adding the ability to render Lit 2D Sprite Entities to an existing URP 2D project something on the roadmap for hybrid rendering?
     
    ll3v3ll likes this.
  26. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    Here is the code how i create the planes:

    Code (csharp):
    1. var archePlane = EntityManager.CreateArchetype(typeof(Translation),
    2.     typeof(Rotation), typeof(LocalToWorld), typeof(RenderBounds), typeof(PerInstanceCullingTag));
    3.  
    4. //filling material dictionary
    5. var mesh = Utils.CreateMesh(planeDivisions, planeSize, 80);
    6.  
    7. for (int i = -(gidSize / 2); i <= (gidSize / 2); i++)
    8. {
    9.     for (int ii = -(gidSize / 2); ii <= (gidSize / 2); ii++)
    10.     {
    11.         var id = new int2(i, ii);
    12.         var rMesh = Utils.CreateRenderMesh(mesh, new Material(WorldManager.Instance.PlaneMaterial));
    13.  
    14.         rMesh.material.SetFloat(Constants.CurrentMeshscaleId, meshScale);
    15.         rMesh.material.SetFloat(Constants.NewMeshscaleId, meshScale);
    16.         _renderMeshDictionary.Add(id, rMesh);
    17.  
    18.         var entity = EntityManager.CreateEntity(archePlane);
    19.  
    20.         EntityManager.SetName(entity, "Plane");
    21.         EntityManager.AddSharedComponentData(entity, _renderMeshDictionary[id]);
    22.  
    23.  
    24.         EntityManager.SetComponentData(entity, new RenderBounds() {Value = rMesh.mesh.bounds.ToAABB()});
    25.         EntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_RenderingLayer
    26.         {
    27.             Value = new uint4((uint) _renderMeshDictionary[id].layer, 0, 0, 0)
    28.         });
    29.  
    30.         EntityManager.SetComponentData(entity, new Rotation());
    31.  
    32.         EntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_WorldTransformParams
    33.         {
    34.             Value = new float4(0, 0, 0, 1)
    35.         });
    36.  
    37.         EntityManager.SetComponentData(entity,
    38.             new Translation {Value = IdMath.GetPlanePositionFromId(id, planeSize)});
    39.     }
    40. }
    41.  
    EDIT: i found that when i disable the light in SCENE! tab i can see my terrain, but this doesnt work ingame when i disable the light
     
  27. Fribur

    Fribur

    Joined:
    Jan 5, 2019
    Posts:
    136
    You are not setting BuiltinMaterialPropertyUnity_LightData and WorldToLocal
     
  28. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    This is for URP, iam using HDRP so i thought i dont need it
     
  29. Fribur

    Fribur

    Joined:
    Jan 5, 2019
    Posts:
    136
    Code (CSharp):
    1. if ENABLE_HYBRID_RENDERER_V2 && UNITY_2020_1_OR_NEWER && (HDRP_9_0_0_OR_NEWER || URP_9_0_0_OR_NEWER)
    2.             // Hybrid V2 uploads WorldToLocal from C# to rendering. Need to refresh it.
    3.             // TODO: Do this on GPU side in the copy compute shader. Would be free in BW bound shader!
    4.             dstEntityManager.AddComponent(entity, ComponentType.ReadWrite<WorldToLocal>());
     
  30. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    1239332

    No project folder but thorough repo steps as it was produced from an empty project using only an asset store asset (which I'm sure you can acquire.)
     
  31. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    I had it, but i forgot to turn the sun intensity up :) it works, thank you
     
  32. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    I just want to give a heads up that we are restructuring some things here to get rid of CPU allocations and time. WorldToLocal and some properties (previous matrix inverse to start with) will move to be tag components.

    Currently we have no good way of documenting and keeping a list up to date on what components you need to get rendering working if you manually create entities. The preferred way is to use a prefab which will make everything be set up correctly, or as you say read MeshRendererConversion.cs and copy relevant paths. However this is subject to change for now while we try to get thinks into a a good shape.
     
  33. Sarkahn

    Sarkahn

    Joined:
    Jan 9, 2013
    Posts:
    440
    Since you guys seem to be moving full steam ahead with this idea that we should always start from converting a prefab then add what we need, it would be really helpful if we had a way to copy all components from one entity to another, or to merge entities basically.

    As it is now we if we have an entity created at runtime that already has a bunch of components and we wanted to make it render, then we have to manually copy the relevant components one by one to or from the instantiated prefab. I don't know if it's possible while still being performant/without using reflection but a CopyAllComponents(Entity a, Entity b) method would be nice.
     
    Last edited: Apr 20, 2020
    wusticality likes this.
  34. gnostici

    gnostici

    Joined:
    Jul 27, 2013
    Posts:
    23
    An entity command buffer can be used to instantiate entities within a query, so we can do that.


    Code (CSharp):
    1. EndSimulationEntityCommandBufferSystem endSimECBSys
    2.      = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
    3.  
    4. var comBuff = endSimECBSys.CreateCommandBuffer().ToConcurrent();
    5.  
    6. Entities
    7.      .WithAny<YourComponentTag>()
    8.      .ForEach((int entityInQueryIndex, Entity entity) =>
    9.      {
    10.           comBuff.Instantiate(entityInQueryIndex, entity);
    11.      }).ScheduleParallel();
    12.  
    13. endSimECBSys.AddJobHandleForProducer(this.Dependency);
    14.  
    15.  
    Lack of typos not guaranteed, but this shows the gist of it. Declare your command buffer system to set a barrier. That determines when the buffer will play back. Your options are beginning of initialization (phase 1), end of initialization, beginning of simulation (phase 2), end of simulation, and beginning of presentation (phase 3). Retrieve that system through World. Then, declare the buffer. Leave off the concurrent and ToConcurrent if you want it on the main thread. Isntantiate clones your entity, at the job index set by (auto-incrementing) Int entityInQueryIndex. Select your entity with your query coming into the ForEach. Schedule parallel, schedule, or run (compiler should prompt you for necessary additional methods). Finally, tell the producer about the job, to make sure it's done.

    If you think you're going to free up memory in the job too early, call Complete() on it to have the main thread wait right then. You can also use this to defer scheduling to a point of your choosing that frame (at least, within that system).

    I'm a bit sleepy, but this should give you plenty to go by searching the documentation.
     
  35. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,264
    That's not the problem. The problem is this: Copying arbitrary component data between 2 entities
     
    eizenhorn and Sarkahn like this.
  36. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    I'm also seeing issues with specific shaders rendering at origin. Is this supposed to be fixed or still incoming?
     
    andywatts likes this.
  37. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Hmm well the shader say's not SRP batcher compatible, so that's probably it.

    Edit: Take that back shader say's it is batcher compatible.
     
    Last edited: Apr 21, 2020
  38. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Instantiating the same entity prefab over and over results in batch counts climbing up consistently. Is that expected?
     
  39. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    So I've been evaluating V2 for handling vegetation. Overall very impressive. Especially the main thread overhead.

    Culling is definitely a weak link. Not sure if it's just not doing an early out where it should or something is requiring touching every instance every time. It performs like it's iterating every instance.
     
  40. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Culling is per instance & on CPU right now. (Early out per chunk, then fine grained per chunk culling)

    You can remove the PerInstanceCullingTag do only do per chunk culling. But then it's important you setup shared components to force entities into some kind of grid / tiles you define yourself so you don't end up with entities from across the map making massively big chunk bounding volumes.
     
  41. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    @tertle :
    The repro steps are too complicated. Please make a project folder and include in the bug report. It is legal to include asset store packages in bugs that you file to Unity. So please file another one with simpler & more reliable repro.
     
  42. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    I'm sorry but my repo steps boiled down to

    1. Download pre built scene from asset store, hit play __ benchmark 1
    2. Download URP package, upgrade materials, hit play __ benchmark 2
    3. Download Hybrid render package, add subscene, hit play __ benchmark 3
    4. Add ENABLE_HYBRID_RENDERER_V2, hit play __ benchmark 4

    If one of these steps is too complicated, I think you guys have a bigger problem on the usability of your package system and asset-store because i really can't see what is complicated about this.

    If I was to upload the project it would literally just be the naked assets from the store as there is literally nothing else in the project. I no longer have this setup. It was just a quick test for our company to compare the performance of different pipelines for a future project.
     
    Last edited: Apr 21, 2020
    axxessdenied and Enzi like this.
  43. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Culling by chunk isn't really, it's still doing per instance work just less of it. It's obvious if you look at how the job cpu time scales with per instance and without.

    It seems to be roughly 25% or so less expensive at best. Which for vegetation isn't enough. Not sure if this is even fixable with how batch render group works?
     
  44. SagisawaFumika

    SagisawaFumika

    Joined:
    Jun 21, 2018
    Posts:
    2
    The Hybrid renderer V2 takes up 1.5G of my memory space, why is that when there are only two materials in the sence?
     
  45. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    Which pre built scene is that?
     
  46. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    It is generally a question of that having many steps means we are not guranteed to look at the same thing. Thats why I am asking you to file a bug with a complete project folder.
     
    rz_0lento likes this.
  47. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    Is this a Shader Graph or a built-in SRP shader such as HDRP/Lit? If yes, it's likely a bug on our side. If it's a custom text shader, then you need to manually implement support for V2, which boils down to the following three things:
    1. Setup instance ID for your shader according to https://docs.unity3d.com/Manual/GPUInstancing.html. Hybrid V2 requires UNITY_SETUP_INSTANCE_ID to work correctly.
    2. For shader properties that you want to override per instance, you need to mark them as DOTS instanced using a new UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata) block. Other properties can only be set per material. This step does not need to be done for built-in properties such as LocalToWorld transform matrices.
    3. For DOTS instanced properties, either replace their usages with UNITY_ACCESS_DOTS_INSTANCED_PROP, or set up macros to do this for you when V2 is enabled. The latter approach is used in Unity built-in code. As with step 2, this does not need to be done for built-in properties.
    4. For practical examples of steps 2 and 3, you can check out the URP file LitInput.hlsl or the HDRP file LitProperties.hlsl

    The shader also needs to enable the DOTS_INSTANCING_ON keyword using "#pragma multi_compile _ DOTS_INSTANCING_ON"

    This is a shortcoming in our current batching implementation. We have a planned optimization to improve behavior when incrementally adding more entities by merging already created batches, but this is not implemented yet.
     
    Last edited: May 4, 2020
  48. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    :)

    VERSUS

    ...and apologies for my useless post
     
  49. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Ya I sort of pieced this together. I was using a third party asset from the asset store since I didn't have any vegetation with SRP shaders, and it was on sale. And they had the basic instancing setup but not the DOTS specific stuff. It seems for complex shaders authors are using SG but then modifying the generated source to get around what's not supported by SG. That was the case here and actually every case I've seen so far.
     
  50. Mordus

    Mordus

    Joined:
    Jun 18, 2015
    Posts:
    174
    Getting very inconsistent results between the hybrid renderer and the standard one. Identical models & materials being lit differently when side by side in the same scene, only difference between them is one has convert to entity and the other doesn't. Is there a way to fix this?
     

    Attached Files:

    • HRV2.png
      HRV2.png
      File size:
      733.3 KB
      Views:
      536
    elJoel likes this.
Thread Status:
Not open for further replies.