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. fnuecke

    fnuecke

    Joined:
    Jul 1, 2015
    Posts:
    8
    Since shader graph is listed as supported, wondering if this is a known issue, didn't find mention of it:
    - Using V2 (define set, cloned hdrp v9.0.0-preview0 tag, Unity 2020.1.0b4)
    - Given a minimal HDRP PBR Master shader graph: the Normal Vector (Object Space) plugged directly into the Normal output, nothing else in the graph
    - Any object using a material with that shader will always render as though its transform were float4x4.identity
    - LocalToWorld holds the correct transform value
    - Culling still appears to operate on the correct transform value
     
  2. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    That sounds like a bug i had with the SRP Batcher putting everything at 0/0/0, but that wasn't for V2 o_O
     
    fnuecke likes this.
  3. fnuecke

    fnuecke

    Joined:
    Jul 1, 2015
    Posts:
    8
    Ah! I didn't think of testing that (since it isn't an issue in v1 for me, hmm), but that's definitely related, if not the same thing: disabling the SRP Batcher does indeed fix it.

    Nevermind... I think I mistook the ECS cube for the reference non-ECS cube in my test scene before because I just woke up. The ECS cube will just completely disappear when I disable the batcher. It shows up in the stats and the frame debugger shows the drawcall, it just never... shows. Will dig some more.


    Update: all right, so, I've created a new project with the HDRP template, added Entities + Hybrid Renderer packages and copied the cloned 9.0.0-preview0 SRP/HDRP packages into Packages dir and... well. Regardless of the V2 define, as soon as I have the "Example Assets" group converted to ECS, things render completely broken and out of place. Disabling SRP Batcher only causes stuff to completely disappear in V2 and seems to make light probes have an effect again in V1 (only difference is in the lighting of the objects). So.. yeah. Will the 9.0.0 that'll go into the package manager do anything different or am I missing anything?
     
    Last edited: Apr 5, 2020
    nicolasgramlich likes this.
  4. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    If you have problems with objects rendering at the origin when using Hybrid V2, you can try re-importing the shader graph to make sure that the shader graph is using V2 code and not V1 code. Switching between V1 and V2 causes a change in how the shader code is generated for shader graphs, and unfortunately the currently released version doesn't automatically re-import when V2 is enabled. A fix for this is being developed.

    There was also another bug that caused specifically the PBR shader graph to work incorrectly with Hybrid V2. That bug has been fixed, and the fix should hopefully be in the next release.
     
  5. cultureulterior

    cultureulterior

    Joined:
    Mar 15, 2015
    Posts:
    68
    It looks like the scriptable render pipeline git repository has been removed/made private?
     
  6. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
  7. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Is there any known issue that would cause HDRP to have totally different lighting intensity once converted to ECS side and using Hybrid Rendering v2?

    I only have convert to entity on the plane mesh here (same happens to all converted HD Lit materials in my testing):


    It doesn't do this if I don't convert to entity or if I use Hybrid Renderer v1.
    I've tested this on 2020.0b4 and on both latest HDRP/staging from Graphics repo and with HDRP 9.0.0-preview.
     
  8. wg-siggig

    wg-siggig

    Joined:
    Mar 17, 2020
    Posts:
    36
    The current package has some bugs with the conversion, so the additional HDLightAdditionalData component is missing causing the unit conversion on the light intensity not to happen.

    Until this is fixed you can manually adjust the intensity with the formula you can get from the normal HDLightAdditionalData monobehavior (look at the intensity set accessor and go from there).
     
    rz_0lento likes this.
  9. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    This is in line what I see here, when I lowered the light intensity I got more like results I expected but then the sky exposure was off and would have needed to recalibrate it with false values. I hope they address this properly soon :)
     
  10. SebLazyWizard

    SebLazyWizard

    Joined:
    Jun 15, 2018
    Posts:
    234
    Yea the lighting issue confused me for ages and until recently I thought it was an issue of HDRP.
     
  11. wg-siggig

    wg-siggig

    Joined:
    Mar 17, 2020
    Posts:
    36
    FYI - If you are using the default Lumen value type, you can add this to your code to get the correct intensity when setting the value.

    Code (CSharp):
    1. var actualIntensity = intensity / (4.0f * Mathf.PI);
     
    florianhanke likes this.
  12. ryanslikesocool

    ryanslikesocool

    Joined:
    Jul 31, 2016
    Posts:
    49
    It might just be me, but it seems that LOD sampling Texture2DArrays aren't working well with Shader Graph and Hybrid Renderer v2 yet. I've got a shader that uses them, but I'm getting <15 frames per second. Performance without that shader is beyond wonderful though, so many thanks for that.
     
  13. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Answered in your thread.
     
  14. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    SRP 9.0.0-preview.14 landed earlier this week. I would however recommend waiting until the next DOTS packages land (including hybrid renderer 0.4.2) to get latest bugfixes. This version also has working HybridHDRPSamples and HybridURPSamples projects in the DOTS repository for testing Hybrid Renderer V2.
     
    Last edited: Apr 9, 2020
  15. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Hybrid Renderer should have no effect on texture sampling in any way. It only affects how per-instance data is provided for the shader. Other shader codegen should be identical. If Texture2DArrays are slower now, I would expect a bug in SRP preview package. If you have a simple repro project, please file a bug report.
     
    ryanslikesocool likes this.
  16. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    DOTS is tracking changes per type per chunk. Accessing a dynamic buffer only affects the version number of that dynamic buffer component of each chunk accessed. So this doesn't cause uploading of any additional GPU data such as LocalToWord or MaterialColor.

    If indeed dynamic buffer read-only access causes version number increase, then that's a bug in DOTS (please report it). For IComponentData based components, the version number is only increased if you have read-write access to the chunk. You should use queries with read-only component access whenever possible. For the new entities.ForEach, read-only access will be enabled by using "in" instead of "ref" for component input parameters in the lambda.

    I recently fixed a bug in the transform system causing update of LocalToWorld of all children every frame if they were in Parent hierarchy. I have also given DOTS tools team some ideas how to improve the entity debugger features for tracking data changes better. Change tracking only works well if you have good tools to validate that you aren't doing unintentional changes.
     
  17. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Yes. RenderMesh is needed for rendering with hybrid renderer. Currently batching is based on Mesh and Material. We have plans to convert Materials for DOTS, and that would remove Material from the shared component, and makes it possible for single batch to include multiple materials. We have also preliminary discussed about the possibility of merging compatible meshes in a subscene to a big vertex/index buffers (single Mesh), then using offsets in draw calls when rendering. This would make it possible to put lots of different meshes (with the same shader) to the same shared component (as they all now share a Mesh). There would be per entity IComponentData containing vertex/index start offsets. Keep in mind that this is one possilble way to solve the issue. We are looking into different approaches before we choose the best one for hybrid renderer.
     
    Last edited: Apr 9, 2020
  18. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    This is fixed now. But I am afraid it just missed the branch off for the next package release.
     
    phobos2077 and nicolasgramlich like this.
  19. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    We could appreciate if you can write a bug report and include a minimal repro project. Or send some screenshots how to setup your materials and shaders.

    To make sure your shaders have been properly compiled after enabling ENABLE_HYBRID_RENDERER_V2, you should delete your project's Library folder. We have implemented a fix for the stale ShaderGraph shaders already, but it missed the next DOTS package release. Will be included in the next one after that.
     
  20. YurySedyakin

    YurySedyakin

    Joined:
    Jul 25, 2018
    Posts:
    63
    I've started this thread with exactly that problem: https://forum.unity.com/threads/need-read-only-access-to-dynamic-buffers.843934/
    Got zero response :(
     
  21. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    What defines a pair of "compatible meshes " and will this feature be available for runtime instantiated entities as well? I maintain SpeckleUnity which is an open source alternative to unity reflect and buildings are pretty much exclusively modelled with unique meshes.
     
  22. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    That's an amazing idea! it's like taking the best from Dynamic and Static batching ^_^
    i think this way the draw calls will be insanely optimized.

    but how about the subscene size and Ram usage? this technique will increase them by alot.
     
    Last edited: Apr 10, 2020
    phobos2077 likes this.
  23. wg-siggig

    wg-siggig

    Joined:
    Mar 17, 2020
    Posts:
    36
    Entities 0.9 is out! :)
     
  24. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Thank you very much for this detailed answer.
     
  25. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    Anyone run into this with Untiy 2020.1.0b5.3485 with latest (burst, hybrid renderer, jobs, collections, entities preview packages)?

    Library\PackageCache\com.unity.rendering.hybrid@0.4.1-preview.6\Unity.Rendering.Hybrid\CopySkinnedEntityDataToRenderEntity.cs(16,26): error CS0246: The type or namespace name 'RenderMeshSystemV2' could not be found (are you missing a using directive or an assembly reference?)
     
  26. Games4Stream

    Games4Stream

    Joined:
    Jan 11, 2020
    Posts:
    5
    You can see in the original post that SRP 9.0.0-preview a requirement. It isn't available yet through the package manager and you have to download it from GitHub and install it manually. I have seen explanations in this forum about how to do it, but I haven't done it yet.
     
    GDevTeam likes this.
  27. axxessdenied

    axxessdenied

    Joined:
    Nov 29, 2016
    Posts:
    33
    To get the preview package simply go to your project folder, go inside the package folder and open up manifest.json and add this line :

    "com.unity.render-pipelines.universal": "9.0.0-preview.14"

    Make sure you have the proper version of unity.
     
    Games4Stream and GDevTeam like this.
  28. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    SRP 9.0.0-preview is now available through the Package Manager but only for Unity 2020.1.x +
     
    GDevTeam likes this.
  29. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    I forgot you can do that in those files. That was spot on what I needed axxessdenied. Thank you.
     
    axxessdenied likes this.
  30. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    So, the build is working now. hyper renderer V2 is showing enabled in Unity 2020.1 beta 5. No Play Mode errors. Packages are all update to date, no issues showing in the Console.

    But, I don't see any entities in the Game window during Play Mode. I see the Entities.Debugger information for them.

    I have a fly camera script on the camera. So I've "flown" rotated all over and still don't see them.

    upload_2020-4-10_14-48-45.png

    It sure seems like I'm missing something surely very simple here? Any ideas all?
     

    Attached Files:

  31. axxessdenied

    axxessdenied

    Joined:
    Nov 29, 2016
    Posts:
    33
    Scroll down in the systems portion of the window in the entity debugger to see if the render system is active. then you can click it and see which components it requires to render an entity. if your entity only has a rendermesh component it doesn't meet the component requirement to be for the render system.
    Are you creating the entities from a prefab or via code?
     
    GDevTeam likes this.
  32. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    290
    i enabled the hybrid renderer v2 via flag as described in the github repo, but now everything is pitch black...

    removing the flag and using the "normal" new v3 renderer, it works fine, but everything is darker.

    Any idea why its pitch black?
     
  33. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Unity.Entities;
    5. using Unity.Mathematics;
    6. using Unity.Transforms;
    7. using Unity.Rendering;
    8. using Unity.Jobs;
    9.  
    10. public class CreateCapsuleSystem : JobComponentSystem
    11. {
    12.     protected override void OnCreate()
    13.     {
    14.         base.OnCreate();
    15.  
    16.         for (int i = 0; i < 1000000; i++)
    17.         {
    18.  
    19.             var instance = EntityManager.CreateEntity(
    20.                 ComponentType.ReadOnly<LocalToWorld>(),
    21.                 ComponentType.ReadWrite<Translation>(),
    22.                 ComponentType.ReadWrite<Rotation>(),
    23.                 ComponentType.ReadWrite<NonUniformScale>(),
    24.                 ComponentType.ReadOnly<RenderMesh>()
    25.                 );
    26.  
    27.  
    28.             float3 position = new float3(UnityEngine.Random.Range(-10, 10), 0, UnityEngine.Random.Range(-10, 10));
    29.             float scale = UnityEngine.Random.Range(1, 10);
    30.             EntityManager.SetComponentData(instance,
    31.                 new LocalToWorld
    32.                 {
    33.                     Value = new float4x4(rotation: quaternion.identity, translation: position)
    34.                 });
    35.             EntityManager.SetComponentData(instance, new Translation { Value = position });
    36.             EntityManager.SetComponentData(instance, new Rotation { Value = new quaternion(0, 0, 0, 0) });
    37.             EntityManager.SetComponentData(instance, new NonUniformScale { Value = new float3(scale, scale, scale) });
    38.             var rHolder = Resources.Load<GameObject>("ResourceHolder").GetComponent<ResourceHolder>();
    39.  
    40.             EntityManager.SetSharedComponentData(instance,
    41.                 new RenderMesh
    42.                 {
    43.                     mesh = rHolder.theMesh,
    44.                     material = rHolder.theMaterial
    45.                 });
    46.         }
    47.     }
    48.  
    49.  
    50.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    51.     {
    52.         return inputDeps;
    53.     }
    54. }
    55.  
    Here's what I had before and it showed a bunch of sheep. Worked with V1 in 2019.3.
     
  34. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    To add, I do not see RenderBounds, which I expected. This has to be something simple I'm overlooking. No one else is posting this issue that Iv'e seen.
     

    Attached Files:

    Last edited: Apr 10, 2020
  35. axxessdenied

    axxessdenied

    Joined:
    Nov 29, 2016
    Posts:
    33
    SebastianAaltonen and GDevTeam like this.
  36. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    Thanks for the follow-up, answer. It's got me perplexed. I did not change the code.
     
  37. axxessdenied

    axxessdenied

    Joined:
    Nov 29, 2016
    Posts:
    33
    hopefully you get it sorted. i feel like I spend more time debugging and figuring out how to do things properly than writing actual code right now messing around with ecs but its fun :)
     
    GDevTeam likes this.
  38. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    Have not found a solution yet.
     
  39. axxessdenied

    axxessdenied

    Joined:
    Nov 29, 2016
    Posts:
    33
    I would start with the basics and create an object in the scene and have it be converted and injected when you load in. Make sure everything is working as it should. From there it would be a matter of debugging what the issue is. I tried generating entities from code and I couldn't get them to render properly so I just instantiate them instead and it ended up working just fine.
    My process ended up being :
    I created a PrefabLibrary entity that loads prefabs and converts them to entities that are stored in the library entity. I can then just bring up the prefab library entity as a singleton and instantiate entities from those template entities..
    I manually create the prefab library system in my bootstrap file and queue which prefabs to load and then run the system only once and disable it. From there my init system will run instantiating the entities I want. Hope that helps.
     
    Attatekjir and GDevTeam like this.
  40. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    upload_2020-4-11_11-6-51.png

    Just updated... Errors everywhere, SRP batcher is going crazy ...
     
  41. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    Thanks again axxessdenied. That's a good point, I'll give that a go.
     
  42. wg-siggig

    wg-siggig

    Joined:
    Mar 17, 2020
    Posts:
    36
    Yeah Im having some issues too. What preview version of HDRP 9.0 are you using? The one in the package manager or from Github?
     
  43. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    GDevTeam likes this.
  44. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    Package Manager.
    In the beginning it's fine, and after like 10 sec it goes buggy. My guess is that Burst finished compiling.
     
  45. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    That did it. Thank you eizenhorn. Here's what I have (with some commented out code) to first get it running now.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Unity.Entities;
    5. using Unity.Mathematics;
    6. using Unity.Transforms;
    7. using Unity.Rendering;
    8. using Unity.Jobs;
    9.  
    10. public class CreateCapsuleSystem : JobComponentSystem
    11. {
    12.     protected override void OnCreate()
    13.     {
    14.         base.OnCreate();
    15.  
    16.         for (int i = 0; i < 1000; i++)
    17.         {
    18.  
    19.             var instance = EntityManager.CreateEntity(
    20.                 ComponentType.ReadOnly<LocalToWorld>(),
    21.                 ComponentType.ReadWrite<Translation>(),
    22.                 ComponentType.ReadWrite<Rotation>(),
    23.                 ComponentType.ReadWrite<NonUniformScale>(),
    24.                 ComponentType.ReadOnly<RenderMesh>(),
    25.                 ComponentType.ReadOnly<RenderBounds>()
    26.                 );
    27.  
    28.  
    29.             float3 position = new float3(UnityEngine.Random.Range(-10, 10), 0, UnityEngine.Random.Range(-10, 10));
    30.             float scale = UnityEngine.Random.Range(1, 10);
    31.             EntityManager.SetComponentData(instance,
    32.                 new LocalToWorld
    33.                 {
    34.                     Value = new float4x4(rotation: quaternion.identity, translation: position)
    35.                 });
    36.             EntityManager.SetComponentData(instance, new Translation { Value = position });
    37.             EntityManager.SetComponentData(instance, new Rotation { Value = new quaternion(0, 0, 0, 0) });
    38.             EntityManager.SetComponentData(instance, new NonUniformScale { Value = new float3(scale, scale, scale) });
    39.  
    40.             //EntityManager.SetComponentData(instance, new RenderBounds { Value = instance.bounds.ToAABB() });
    41.             //EntityManager.SetComponentData(instance, new RenderBounds { Value = instance.bounds.ToAABB() });
    42.  
    43.             var rHolder = Resources.Load<GameObject>("ResourceHolder").GetComponent<ResourceHolder>();
    44.  
    45.             EntityManager.SetSharedComponentData(instance,
    46.                 new RenderMesh
    47.                 {
    48.                     mesh = rHolder.theMesh,
    49.                     material = rHolder.theMaterial
    50.                 });
    51.  
    52.             EntityManager.SetComponentData(instance, new RenderBounds()
    53.             {
    54.                 Value = new AABB()
    55.                 {
    56.                     //Center = new float3(mesh.bounds.center.x, mesh.bounds.center.y, mesh.bounds.center.z),
    57.                     //Extents = new float3(mesh.bounds.extents.x, mesh.bounds.extents.y, mesh.bounds.extents.z)
    58.                 }
    59.             });
    60.         }
    61.     }
    62.  
    63.  
    64.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    65.     {
    66.         return inputDeps;
    67.     }
    68. }
    69.  
     
  46. GDevTeam

    GDevTeam

    Joined:
    Feb 14, 2014
    Posts:
    90
    I also got the ECSSamples (one of the examples there) running just before this RenderBounds() code-add and run. I was getting ready to consolidate my finding into a new project. This took care of that need. Thanks again to everyone helping.
     
  47. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    I think it's likely that this error is caused by running out of space in the GPU buffer we use for storing rendering data. We have optimizations coming up that will reduce the amount of memory used per entity, and support for using a larger buffer for scenes that have a lot of entities and a lot of data per entity.

    We should also improve the error messages in these situations so it's more obvious what is going on.
     
    GilCat, Opeth001 and wg-siggig like this.
  48. yareth

    yareth

    Joined:
    Sep 20, 2019
    Posts:
    2
    I'm having trouble getting material property overrides to work.
    Added ENABLE_HYBRID_RENDERER_V2 define.
    Created 2D Renderer -> Sprite Lit graph.
    Added properties to override, checked Hybrid Instanced.
    Set up conversion to add needed components with MaterialPropertyAttribute.
    Confirmed that the components are added with proper values.
    Still Hybrid Renderer does not override the properties. I've tracked the problem to HybridV2ShaderReflection.GetDOTSInstancingProperties() returning empty list, but no idea what to try next.
    Using 2020.1.0b5 and latest previews of SRP, Hybrid Renderer and other needed packages.
    Double checked the manual, but I don't think I missed something.
    Any clue why its not working?

    One of the properties:

    Code (CSharp):
    1. [MaterialProperty("TexturePivot", MaterialPropertyFormat.Float4)]
    2. public struct PixelizedTexturePivot : IComponentData
    3. {
    4.     public float4 Value;
    5. }
    upload_2020-4-16_4-7-42.png upload_2020-4-16_4-11-9.png
     
    Last edited: Apr 16, 2020
  49. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    Hybrid V2 doesn't support Sprite Lit Graphs yet. I will file a feature request for that.
     
    ll3v3ll, OldMage and yareth like this.
  50. SebastianAaltonen

    SebastianAaltonen

    Unity Technologies

    Joined:
    Feb 21, 2020
    Posts:
    112
    You are missing a lot of essential components in the entity. I recommend instantiating prefabs to get all the correct components on your entities. Instantiating prefabs is also faster than writing your own C# code to add each component to the entity.
     
Thread Status:
Not open for further replies.