Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug Materials registered with the EntitiesGraphicsSystem at runtime break when maximising game view

Discussion in 'Graphics for ECS' started by Shinyclef, Oct 18, 2023.

  1. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    507
    Hello unity graphics people. A little bug report here:

    At runtime, I duplicate a material, and register the new matierial with the entities graphics system (EntitiesGraphicsSystem.RegisterMaterial). I get back the material ID which I assign to the MaterialMeshInfo component. This all works correctly. But when I maximise the game view (by double clicking on the game tab), all the materials break and I'm left with the pink shader error. This does not happen when I use materials that are not registered with the EntitiesGrpahicsSystem at runtime.

    See below for before and after maximising the game view. Note that, yes, those little pink things are in fact the same mesh with a broken shader (I do a lot of vertex and shader work to trace the voxels).

    Small code snipped:
    Code (CSharp):
    1.  
    2. Material mat = new(material);
    3. mat.SetBuffer(blocksBufferMatId, buffer);
    4. materialMeshInfo.MaterialID = graphicsSystem.RegisterMaterial(mat);
    5. // ...
    6. // materialMeshInfo is set to the object being rendered, which then breaks when I maximise. It doesn't break if I just use a material that wasn't registered at runtime.
    7.  
    Working before maximising:


    After maximising: (it works fine if I start with the game view already maximised)


    Makes it very hard to work :(.
     
  2. VincentBreysse

    VincentBreysse

    Unity Technologies

    Joined:
    May 31, 2021
    Posts:
    28
    Which Entities Graphics package version are you running with? Is it 1.1+ or is it 1.0? MaterialMeshInfo received a few updates in 1.1, so maybe a bug slipped in at some point.

    Although, since you need to maximize the window to trigger the bug it might have to do with the way the BatchRendererGroup is keeping material IDs up to date internally. It's possible that maximizing the window has a few side effects which are not correctly handled.

    In any case, could you please make a ticket with a repro project for this?
     
  3. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    507
    Hey there, I am using Entities Graphics 1.1. Made a bug report with a simple repro.
    Bug ticket: IN-57937

    If you do find any workarounds let me know.

    Cheers.
     
  4. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    507
    There's something I forgot to mention which seems relevant. If you un-maximise an already maximised game view, it does not break; it only breaks when maximising, not un-maximising. It also doesn't care about window resizes.