Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Entities Invisible with Hybrid Renderer v2

Discussion in 'Graphics for ECS' started by PublicEnumE, Apr 29, 2020.

  1. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    Apologies if this has been covered elsewhere - I found several threads about invisible entities with older versions of these packages, but not much about this specific config:

    When I enable Hybrid Renderer v2, my entities no longer render. Here's my current setup:

    Unity: 2020.1.03b6.3521
    Installed Packages:
    • Entities: 0.9.1 preview.15
    • Hybrid Renderer: 0.4.2 preview.16
    • High Definition Render Pipeline: 9.0.0 preview.13
    I have ENABLE_HYBRID_RENDERER_V2 set in my player defines. I've also run through the process of updating all of my project's materials when installing HDRP (and I had no custom materials in my project).

    The entities I want to render all have the following components:
    • BuiltInMaterialPropertyUnity_MatrixPreviousM
    • BuiltInMaterialPropertyUnity_MatrixPreviousMI
    • BuiltInMaterialPropertyUnity_MotionVectorsParams
    • BuiltInMaterialPropertyUnity_RenderingLayer
    • BuiltInMaterialPropertyUnity_WorldTransformParams
    • RenderBounds
    • WorldRenderBounds
    • LocalToWorld
    • WorldToLocal
    • RenderMesh
    • PerInstanceCullingTag
    • HybridChunkInfo
    • ChunkWorldRenderBounds

    Switching back to Hybrid Renderer v1 will still render the entities.

    Any idea what I should look for here? Having trouble finding info about this. Thank you very much for any pointers.
     
    Last edited: Apr 29, 2020
    NoFuchsGavin and MNNoxMortem like this.
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,509
    What's your shader? Just default?
     
  3. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    Yes, just The default material on some spheres.

    Performance is great, though. ;)

    Any ideas?
     
  4. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    If I create a blank scene, create a basic sphere from the 'GameObject/3D Object' menu, and then put a ConvertToEntity component on it, should I expect it to render when I go into play mode?
     
  5. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,509
    Just tested, that works fine for me. Creates the sphere with HDRP/lit and appears in scene.

    upload_2020-4-30_9-7-8.png
     
  6. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    Thank you for running through that. Do you have the same package versions as I do?

    Well, let's see if Unity will take kindly to me removing, uninstalling, and then reinstalling all of these packages! I read that once you install the HDRP package, there may be issues trying to remove it.
     
  7. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,509
    I was in b7 but I had no issues with b6 previously as far as I'm aware.

    I did have some issues with HDRP working at all the first time I set it up and had to revert all project settings to get it to actually render anything.
     
  8. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    Hmm, I have a feeling the shader conversion process never got a chance to complete. I remember it hanging at around 45% the first time I installed HDRP. I restarted the editor, and clicked a button in the starting menu to manually convert them again, but this seemed to complete instantly. At the time, I thought this was evidence that it actually had completed previously, and that it was the Unity UI which bugged. Now I'm suspicious.

    I'm trying this again in a clean project to verify that I can get it to work at all. If I can locate where Unity stores the new shaders it creates during this conversion process, maybe I can delete them and actually have lock restarting that process.
     
  9. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    Yep, it's working in a fresh project. Hope I can track down the location of that data...
     
  10. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    729
    Just started a new project with Hybrid Render and HDRP, and I'm running into the same problem. Materials are all converted. Non-converted objects render fine. Converted entities don't render at all.

    No idea what's up.
     
    NoFuchsGavin likes this.
  11. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    When I upgraded all the packages to the latest versions, it turned out that none of my materials were rendering because of an error in a custom shader. Wireframe mode was showing my entities just fine though
     
    erenaydin likes this.
  12. Radivarig

    Radivarig

    Joined:
    May 15, 2013
    Posts:
    70
    Same for me on URP, blank scene with new cube and attach covert to entity, nothing is rendered, but non etities are

    Unity 2020.1.4f1
    "com.unity.entities": "0.14.0-preview.18",
    "com.unity.render-pipelines.universal": "9.0.0-preview.55",
    "com.unity.rendering.hybrid": "0.8.0-preview.18",
     
  13. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,509
    Have you enabled V2? And what shader are you using?
     
  14. Radivarig

    Radivarig

    Joined:
    May 15, 2013
    Posts:
    70
    @tertle yes, I've added `ENABLE_HYBRID_RENDERER_V2` under `player settings > scripting define symbols` and got the activation log message that it was active. Shader is the default `Universal Render Pipeline/Lit`, same with unlit. If I switch back to V1 entities render
     
  15. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    Are you using subscenes? Try closing the subscene.
     
  16. Radivarig

    Radivarig

    Joined:
    May 15, 2013
    Posts:
    70
    @elJoel simple new blank scene without subscenes
     
  17. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    288
    I have the same problem, but only for "some" objects .. The solution is to move them a little bit.

    Apparently this is a problemwhere gpu data and cpu data is not aligned correctly, but they are aware of it
     
  18. Radivarig

    Radivarig

    Joined:
    May 15, 2013
    Posts:
    70
    @Cell-i-Zenit do you know if there's an opened issue I can follow?
     
  19. Radivarig

    Radivarig

    Joined:
    May 15, 2013
    Posts:
    70
    @Cell-i-Zenit what do you mean by move them a bit? I have a move system that is changing their Translation and those changes are visible in the Entity Debugger
     
  20. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    288
    by moving iam talking about moving their position just slightly .. for me the objects instantly appear again.

    There is no open issue as far as i know
     
  21. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    296
    Did anyone find anything more out about this?

    Out of seemingly nowhere suddenly none of my entities render with hybrid v2, working one second, not working the next. Since then I've tried restarts, deleting the Library folder and more.

    Inspecting entities in the entity debugger show correct transform data.

    Even adding a cube with a convert to entity doesn't work since this started going wrong.

    When removing the hybrid v2 define I get this compile error:
    Library/PackageCache/com.unity.shadergraph@9.0.0-preview.34/Editor/Importers/ShaderGraphImporter.cs(25,6): error CS0246: The type or namespace name 'ScriptedImporterAttribute' could not be found (are you missing a using directive or an assembly reference?)


    Does anyone know how to resolve that?

    Ideally I'd not disable v2 but I'm struggling to find a way round this. Debugging ideas welcome.

    Unity 2020.2.0b2.3094
    Entities 0.14-preview.19
    Hybrid Renderer 0.8.0-Preview.19
    Jobs 0.5.0Preview.14
    Universal RP 9.0.0-preview.35
    Burst 1.3.6

    This has all been working for a while but has suddenly stopped. Not sure what could have caused this.
     
    Last edited: Sep 25, 2020
  22. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    What packages/unity versions? What render pipeline? Are you seeing the "Hybrid Renderer V2 active" console log?
     
  23. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    296
    Added to original post. Yes I am seeing it show as active.
     
  24. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    296
    Managed to switch back to hybrid renderer v1 and everything working again, switched to v2 once more just to be sure and things stopped rendering so I'll stick with v1 for now.
     
    Last edited: Sep 25, 2020
    adammpolak likes this.
  25. inspoy_tap4fun

    inspoy_tap4fun

    Joined:
    Oct 23, 2020
    Posts:
    1
    I found that only the default lit material "Packages/com.unity.render-pipelines.universal/Runtime/Materials/Lit.mat" can be rendered
    Other materials with custom shadergraph(also include built-in SimpleLit.mat) are invisible

    Using URP and converted to entities

    Entites: 0.16.0-preview.21
    Hybrid Renderer: 0.10.0-preview.21
    URP: 10.0.0-preview.26
     
  26. Srokaaa

    Srokaaa

    Joined:
    Sep 18, 2018
    Posts:
    169
    Did you turn SRP batcher on? For me everything was invisible until I turned it on
     
    nixarn_ likes this.
  27. vectorized-runner

    vectorized-runner

    Joined:
    Jan 22, 2018
    Posts:
    347
    I have the same issue. Just updated my project to 2020.2.0b14, using Hybrid Renderer 0.10.0-preview.21 and single Cube converted to entity on a empty scene is not rendering. Disabling SRP Batcher fixes it.
     
    nixarn_, Sarkahn, kennel_ and 2 others like this.
  28. hypertd

    hypertd

    Joined:
    Mar 6, 2017
    Posts:
    2
    I just wanna confirm that this worked for me also when creating a scripted entity.

    The object converted using the "convert to entity" script seem to render fine. It feels like a flag is missing in order render scripted entities correctly. You can inspect and compare the two, you'll notice layer and material properties are added. This is possibly why its suggested to use a prefab not something from scratch.
     
    reeseschultz and kennel_ like this.
  29. reeseschultz

    reeseschultz

    Joined:
    Apr 1, 2018
    Posts:
    21
    I encountered this issue a while back and disabling the SRP batcher resolved it, but after upgrading the editor (to any newer version or beta), I encountered this issue again, despite the SRP batcher being toggled off.

    I had to enable the SRP batcher, press play, stop playing, then disable it. After that my entities reappeared in play mode. I see no changes via Git. Spooky and annoying. Can someone from Unity please look into this? There's obviously a problem. Disabling the SRP batcher is not even a solution, it's a regrettable workaround.
     
    Ziddon likes this.
  30. Sarkahn

    Sarkahn

    Joined:
    Jan 9, 2013
    Posts:
    440
    Definitely a frustrating change. Having it silently fail is horrible - it should at least throw a warning if srp batching is enabled to let you know hybrid renderer is incompatible.
     
    adammpolak and florianhanke like this.
  31. adammpolak

    adammpolak

    Joined:
    Sep 9, 2018
    Posts:
    447
    How do you disable SRP Batcher?
     
  32. vectorized-runner

    vectorized-runner

    Joined:
    Jan 22, 2018
    Posts:
    347
    From the UniversalRenderPipelineAsset in your project, in the advanced tab
     
    adammpolak likes this.
  33. reeseschultz

    reeseschultz

    Joined:
    Apr 1, 2018
    Posts:
    21
    All right, I created the succinctly-named PostAuthoringURPHybridRendererV2Bug GitHub repository reproducing and proving that there is a bug that needs to be fixed here. The README goes into reasonable detail.



    The gist: entities created during authoring work fine, but entities created post-authoring (runtime) are invisible. All you have to do is clone my repo, play the sample scene and take a look at the entity debugger.

    Can someone from Unity please do this? I took the time to put this together for you.

    Edit: By the way, I can only spawn entities at runtime by reverting to Hybrid Renderer V1 with the versions listed in the README.
     
    Last edited: Jan 5, 2021
  34. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,509
    I don't really get your example. From what I can tell your runtime entity archetype is Cube + Translation? Why would you expect that to render? You're missing about 10 required components.
     
  35. reeseschultz

    reeseschultz

    Joined:
    Apr 1, 2018
    Posts:
    21
    @tertle, no, I'm not missing any components. Also, FYI, you shouldn't talk to people like that, it's disrespectful. Dismissive responses attempting to make someone else look stupid are generally classified as toxic behavior.

    You're failing to take into account the cube authoring script that injects the cube prefab into the scene as an entity on startup. Thus, the GameObject components are converted into entity-component equivalents, hence why, if you actually checked the Entity Debugger, you would verify that there's a
    RenderMesh
    along with various other components there that are, I would agree, required. They're not missing lol.

    Look at this screenshot:



    Oh, look at all those cubes I created that are invisible in spite of having all of those components on them. This is actually how I spawn things in my demo project that you will see works. I use prefabs just like this. I only add components related to the custom navigation systems.
     
  36. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,509
    I'm not really sure how me not understanding your example was disrespectful, I just wasn't understanding the setup from simply looking at your system on github. I apologize. I didn't have 2020.2 installed to check it in editor as it has huge issues with entities at the moment to the point I don't believe it's usable until fixes in 0.17 come out.
     

    Attached Files:

    Last edited: Jan 5, 2021
  37. nixarn_

    nixarn_

    Joined:
    Jul 25, 2015
    Posts:
    42
    Same thing happens for me. Works with the SRP Batcher turned off. I hope unity gives posts about Dots future soon, what will be v.1.0 and when is it expected.
     
  38. jasons-novaleaf

    jasons-novaleaf

    Joined:
    Sep 13, 2012
    Posts:
    181
    I switched my test project to use the v2 Hybrid Renderer and now get a blank project. Either I don't have "UniversalRenderPipelineAsset" or I can't find it in my project. Could you give me a bit more detail? I'm using Unity 2020.2 and hybrid renderer 0.10.0-preview.21

    Sorry I'm a Unity noob, just learning via a DOTS udemy course, so I admit I'm missing most the baseline unity editor knowledge that everyone else has.
     
  39. vectorized-runner

    vectorized-runner

    Joined:
    Jan 22, 2018
    Posts:
    347
    Try Edit->Project Settings->Graphics->Scriptable Render Pipeline Settings
     
    jasons-novaleaf likes this.
  40. jasons-novaleaf

    jasons-novaleaf

    Joined:
    Sep 13, 2012
    Posts:
    181
    Thank you, it was blank so figured out I need to make a UniversalRenderPipelineAsset to put in there. something else to learn!
     
    vectorized-runner likes this.
  41. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    195
    The required components for spawning entities from code has sadly changed a bit over time. The simplest way of spawning things is by spawning prefabs, which has been converted to entities and there fore has all the required components. If this is not possible you will need to ensure the entities has all the needed components yourself. In Entities 0.17 package drop (Hybrid Renderer 0.11 IIRC) we have created a utility for you to use and that we use in the conversion system as well. Hopefully this will make it easier to spawn game objects from code without having things break between versions. We are still changing the data model slightly from time to time to reduce memory usage and this requires us to change what components are needed and not.

    If you are not on Hybrid Renderer 0.11 you can have a look in com.unity.rendering.hybrid/Unity.Rendering.Hybrid/MeshRendererConversion.cs in the package (specifically AddComponentsToEntity) to see what components are added during conversion and mimic this when spawning at runtime. It's this code that has moved to a runtime available utility in the new release.

    Hope this helps.
     
    Last edited: Jan 8, 2021
  42. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    288
    Well the current prefab spawning is still not sufficient... i saw that we need to add hdrp emissions by ourselves because it gets removed
     
    AznableMiao and reeseschultz like this.
  43. Arycama

    Arycama

    Joined:
    May 25, 2014
    Posts:
    181
    2020.2 appears to have broken BatchRendererGroup when SRPBatcher is enabled.
    This is what the Hybrid Renderer uses under the hood.

    I've experienced this in a custom SRP, and was also able to reproduce it in an empty project with the URP.
    I'm hoping the bug report gets looked at soon.

    https://fogbugz.unity3d.com/default.asp?1307714_5778k36lo52uh1sp
     
  44. LevonVH

    LevonVH

    Joined:
    Dec 16, 2016
    Posts:
    13
    I am building a new project with 2 cubes, one is a game object and the other is converted to an entity. Both are rendered on android and on Oculus Quest 2. But when I enable the XR management plugin the entity cube is no more rendered. I have hybrid V2 enabled and using the latest packages. Disabling the SRP batcher doesn't solve it. Maybe someone has an Idea on this?
     
  45. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    This explains why moving from hybrid 0.10 to Version 0.11.0 I get invisible renders, but only some of my meshes disappear. At this point it's probably better to make my own custom render system, as Hybrid has issues when I update it, and unity doesn't seem to want to document the changes from a coding perspective. Unless of course, have they updated their cube hybrid examples? That would count as documentation. But I wish the Hybrid official documentation would contain an example for spawning a RenderMesh and give all the right components, even a simple list and example data involved. I think using it atm when it breaks like this is a liability over time.
     
    Last edited: Feb 15, 2021
  46. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    195
    Good news then (I hope). Samples for hybrid usage is now published at https://github.com/Unity-Technologies/EntityComponentSystemSamples
    There is also a utility in 0.11 to fully set up a renderable entity so you don't have to guess what components you need.
     
    deus0 likes this.
  47. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    814
    Samples are great, thanks!
     
    deus0 likes this.
  48. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    Hi! Firstly, Thank you for the updated examples! I was looking through the examples but I couldn't find any use of EntityArchetype. There seems to be a lot more empathizes on GameObject uses with ECS rather then spawning from code. Which I understand, as it's a more human friendly workflow. However my current workflow is spawning from code in parallel using command buffers, then randomizing the starting component data using authored inputs that I set with Scriptable Objects as well as some simulation math magic. I don't have much use for authoring individual datas as such. Perhaps I missed something in the examples? I checked the cube and boid examples of spawning and seemed to differ in this, compared to 2018 examples! (I probaly missed something..)
     
  49. Sarkahn

    Sarkahn

    Joined:
    Jan 9, 2013
    Posts:
    440
    https://docs.unity3d.com/Packages/c...brid@0.11/manual/runtime-entity-creation.html
     
  50. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    I see but '

    // Call AddComponents to populate base entity with the components required
    // by Hybrid Renderer
    RenderMeshUtility.AddComponents(
    prototype,
    entityManager,
    desc);'

    Cannot be used in a parallel job right? And it doesn't really tell you what components are needed. For example, I need to manually update render bounds when I create my UI entities. So it's more important to know exactly what components are there. It's more a blackbox!