Search Unity

Deleted

Discussion in 'General Graphics' started by JWLewis777, Sep 19, 2021.

  1. JWLewis777

    JWLewis777

    Joined:
    May 17, 2015
    Posts:
    46
    Post Deleted
     
    Last edited: Feb 23, 2022
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,734
    If you want them to be instanced you have to use DrawMeshInstanced instead of DrawMesh.
     
    hippocoder likes this.
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,734
    The tl;dr is

    You create a Matrix4x4[] with all the transforms.

    You set it in a for loop like:

    myMatrices.SetTRS(calculatedPositionToUse, Quaternion.identity, Vector3.one);

    And then call somewhere once per frame

    Graphics.DrawMeshInstanced(myMesh, 0, myMaterial, myMatrices);

    And that should get you started
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's not a particularly important limit, it's trivial to have multiple sets of 1024. If you're trying to bypass anything, you should instead spend that extra work on DrawMeshInstancedIndirect

    And that's where you draw millions without overhead.
     
  5. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    On the toppic of,
    Does anyone know how to instance mesh with CommandBuffer.DrawMeshInstanced and make it look the same as Graphics.DrawMeshInstanced?

    With command buffer either lights or shadows doesn't look the same;
    Graphics.DrawMeshInstanced works, but it has more overhead.