Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Maximum number of submeshes limited to 32

Discussion in 'HDRP Ray Tracing' started by visose, Aug 31, 2020.

  1. visose

    visose

    Joined:
    Nov 2, 2014
    Posts:
    28
    When loading a mesh to the scene with more than 32 submeshes, I get an index out of range exception in HDRaytracingManager.cs, in line 202:
    subMeshFlagArray[meshIdx] = true;

    This limit seems hardcoded earlier on in line 80:
    const int maxNumSubMeshes = 32;

    Is there a reason for this limit? I might need meshes with hundreds of submeshes.
     
  2. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Hello Visose, I managed to repro your issue and logged a bug.
    Since it's a an edge case, it won't a be high priority but I agree that it should at least fail gracefully.

    AFAIK, there's no specific reason for the limit currently, apart from needing a "reasonable limit"
    What's your specific use case that makes you need to have that many submeshes ?
     
    Last edited: Sep 1, 2020
  3. visose

    visose

    Joined:
    Nov 2, 2014
    Posts:
    28
    Thank you. We have some geometry that is a solid object made of many individual faces, where each face is made of multiple triangles. We are currently storing each face as a submesh in the render mesh. One reason is we want to be able to hover and select the individual faces and change the material of the face that is currently being hovered/selected. We can do this easily with submeshes. We could work around this by storing separately from the mesh the triangles that represent each face. And when hovering/selecting, regenerating the mesh so that it has one submesh for the selected face and the rest for non selected. We also want to apply different materials to different faces, so we need to create at least one submesh per material (but not as many as unique faces). It's just that this solution seems unnecessarily convoluted if we didn't have a submesh limit. All of this (materials being assigned to faces) would be constantly changing at runtime.
     
    Last edited: Sep 2, 2020
  4. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I've run into this before on one test scene and there I just upped the limit from HDRP source code. I did notice a correlation between this value and the performance (that wasn't explained by just more submeshes itself on the meshes in the scene).

    As additional note, this PR handling the error has now been merged to HDRP/staging branch: https://github.com/Unity-Technologies/Graphics/pull/1757
     
  5. auzaiffe

    auzaiffe

    Unity Technologies

    Joined:
    Sep 4, 2018
    Posts:
    255
    Yes the issue was handeled in the meantime, thanks for reporting it.
     
  6. visose

    visose

    Joined:
    Nov 2, 2014
    Posts:
    28
    Is the commit that handled this issue present in any released version of the package?
     
  7. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Should be in the 10.1.0 package (and after)