Search Unity

Bug Entites Graphics 1.0.0-pre.15 SkinnedMeshRenderer transform baking issue

Discussion in 'Entity Component System' started by Rukhanka, Dec 14, 2022.

  1. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    204
    The Entities Graphics package has an issue with transforms while baking SkinnedMeshRenderers. Inside Entities Subscene SkinnedMeshRenderers handled incorrectly:

    It is some difference between ordinary "Lit" and manually created ShaderGraph shader with "Compute Deformations" node. But in both cases transforms are wrong.

    Version 1.0.0-exp.14 does not have this issues
     
    Last edited: Dec 14, 2022
  2. WhisperPine

    WhisperPine

    Joined:
    Jun 29, 2017
    Posts:
    2
    I encountered the same issue.
    Specifically, the world position of the entity is doubled from the world position of its original GameObject.

    From the Entities Hierarchy window, you can find out the GameObject was baked into two nested entities.
    And both of them have the same value of LocalTransform, which leads to the doubled result.

    I'm pretty sure this issue is caused by the baking process.
     
  3. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    204
    Hi. Thank you for clarification. I am almost ready to release animation system for DOTS, but this issue is preventing me to move to the latest version for Entites Graphics package.
     
    lclemens likes this.
  4. Tigrian

    Tigrian

    Joined:
    Mar 21, 2021
    Posts:
    124
    Hello,

    I also encountered the same issue,
    There is a simple workaround, which is using a baking system to manually reset the LocalTransform of the Entity holding the RenderMesh Component. It worked in my case, hope it allows you to upgrade. I was lucky enough to have a baking system already, to do some other stuff, so in my case, it was just adding one line of code. But making a system like that, to handle all the cases, should work (not tested, though).
    Code (CSharp):
    1.    
    2. [WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
    3. public partial class ResetRenderEntityLocalTransformBakingSystem : SystemBase
    4. {
    5.     protected override void OnUpdate()
    6.     {
    7.         var ecb = new EntityCommandBuffer(Allocator.TempJob);
    8.  
    9.  
    10.         Entities
    11.             .ForEach((Entity entity, in DynamicBuffer<AdditionalEntitiesBakingData> additionalEntities) =>
    12.             {
    13.                 foreach (var rendererEntity in additionalEntities.AsNativeArray())
    14.                 {
    15.                     if (EntityManager.HasComponent<RenderMesh>(rendererEntity.Value))
    16.                     {
    17.                         ecb.SetComponent(rendererEntity.Value, LocalTransform.Identity);
    18.                     }
    19.                 }
    20.             }).WithEntityQueryOptions(EntityQueryOptions.IncludeDisabledEntities).WithoutBurst().WithStructuralChanges().Run();
    21.  
    22.         ecb.Playback(EntityManager);
    23.         ecb.Dispose();
    24.     }
    25. }
    26.  
     
    JustAWitness and Rukhanka like this.
  5. kite3h

    kite3h

    Joined:
    Aug 27, 2012
    Posts:
    197
    The entity with MaterialMeshInfo has been changed to be linked to the root.
    But at that time, it carries the current localTransform value.
    So, you can attach a tag and replace the localTransform value with an appropriate value while removing the tag.
    The code above doesn't work because the RenderMesh is gone now. And since all usable components have been changed to internal, they cannot be modified without modifying the package code.
    And that problem is nothing compared to the next problem.
    upload_2023-1-18_20-21-6.png

    Applying DOTS instancing in the shader looks like this:

    There seems to be a serious flaw in the use of the RAW buffer.
     
    Last edited: Jan 18, 2023
  6. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,267
    This definitely looks like a bug in MeshRendererBakingUtility and Transforms V2. If there is a root bone to attach to, it assigns the Transform.LocalToWorldMatrix to the LocalTransform component, rather than the WorldTransform component. It also assigns a Parent and never assigns a WorldTransform nor a ParentTransform.
    I'm quite curious about this issue. Can you elaborate more? What RAW buffer are you referring to?