Search Unity

Graphics.DrawMeshInstanced(); not rendering shadows at certain camera angles

Discussion in 'General Graphics' started by Ardinius, Jul 14, 2018.

  1. Ardinius

    Ardinius

    Joined:
    Oct 4, 2015
    Posts:
    57
    Hi all,
    Please see https://imgur.com/a/YKeKoq3 for example screenshots.

    I am using Graphics.DrawMeshInstanced(); to render a forest scene successfully, but when flying through the scene shadows suddenly disapear and then pop back in depending on camera angle (possibly also camera posistion).
    Has anyone seen this before or any idea what may be the cause?

    I assume that Graphics.DrawMeshInstanced(); still uses project settings/quality/ shadow settings.

    I create a Matrix4x4[] matrixList, and fill it with a Matrix4x4.TRS(translation, rotation, scale) for each tree.
    then i call from Update()
    Graphics.DrawMeshInstanced(mesh, 0, material, matrixList);

    Using Unity 2018.2
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    How many instances are you rendering?
    Wich graphics API does this happen on?
     
  3. Ardinius

    Ardinius

    Joined:
    Oct 4, 2015
    Posts:
    57
    6700 instances, using directx11
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
  5. Ardinius

    Ardinius

    Joined:
    Oct 4, 2015
    Posts:
    57
    Sorry i should have been more clear, i am batching them into max groups of 1023

    Start()
    int count = forrestmapData.numberOfTrees;
    matrix = new List<Matrix4x4[]>();
    while (count>1023)
    {
    matrix.Add(new Matrix4x4[1023]);
    count -= 1023;
    }
    matrix.Add(new Matrix4x4[count]);

    Update()
    foreach (Matrix4x4[] matrixList in matrix)
    {
    Graphics.DrawMeshInstanced(mesh, 0, material, matrixList);
    }

    What i have just found out, is that Graphics.DrawMeshInstanced() shadows are never rendered in builds of the game either.
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,019
    ok, it's hard to tell what's going on then :)
    Please submit a bugreport.
     
  7. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    HEy @Ardinius, did you solve this issue? I'm on 2020.1 and experience the same thing.