Search Unity

Calling SetVertices on a dynamic mesh cases the mesh to disappear.

Discussion in 'General Graphics' started by SaharaBob, Apr 4, 2021.

  1. SaharaBob

    SaharaBob

    Joined:
    Jul 30, 2018
    Posts:
    15
    For what it's worth, there appears to be a breaking change in 2021.1.0f1 in the way Keep Quads is applied when a FBX is imported.

    I have a very simple project using the standard builtin / legacy render pipeline to test the relative performance of CPU vs Burst for deforming a mesh. The mesh is a FBX exported from Blender and is a square plane 2 units per side and with 100 vertices per edge (i.e. I've pre-tessellated it so the CPU and Burst have plenty of work to do). In code I manipulate the vertices to simulate the surface of a fluid by displacing the vertices vertically using a perlin noise function. In the FBX import options I have Keep Quads enabled. in Start() I call MarkDynamic() on the mesh before retrieving the vertices and normals.

    In 2020.2.7f1 everything works as expected; I see the noise function scrolling smoothly across the surface with recalculated normals giving the expected light and shadow areas.

    Upgrading the project to 2021.1.0f1 and making no changes except those forced upon me by the upgrade causes the mesh to display with displaced vertices for one frame then it ceases to be visible on screen even though it is still present in the scene and the frame rate suggests Unity is trying to render it. If I comment out the call to MarkDynamic the mesh doesn't display at all. If I uncheck Keep Quads , apply the change, and re-run then it works as it did in 2020.2; or at least it appears to.

    I infer from this that if:
    1. One has a FBX model containing quads.
    2. Keep Quads is checked in the FBX import options.
    3. The mesh vertices are modified in code - using either plain old C#, or Burst.
    then starting with 2021.1.0f1 Unity may fail to render the mesh correctly after the first frame.

    I can't see anything obvious in the release notes (https://unity3d.com/unity/whats-new/2021.1.0) documenting or linking to the documentation for this change.

    Hope this helps anyone else with this problem.
     
  2. George-Ing

    George-Ing

    Unity Technologies

    Joined:
    Jan 14, 2020
    Posts:
    78
    Hey!

    I agree, this sounds like a potential issue. If it's not too much hassle, could you file a bug report with your project & our team will look into it.

    Thanks!
     
  3. SaharaBob

    SaharaBob

    Joined:
    Jul 30, 2018
    Posts:
    15
    Hi, thanks for the reply.

    No problem, I've submitted issue 1327826.
     
  4. George-Ing

    George-Ing

    Unity Technologies

    Joined:
    Jan 14, 2020
    Posts:
    78
    Thanks, you're an absolute star!