Search Unity

Question New mesh api and custom vertex attributes

Discussion in 'General Graphics' started by VictorKs, Dec 20, 2022.

  1. VictorKs

    VictorKs

    Joined:
    Jun 2, 2013
    Posts:
    242
    So I looked at the new Mesh API and it looks much more like DX11 style setting attribute layouts and custom streams. So besides faster procedural mesh generation and Job System support what new workflows are possible now?

    Also is it possible to set our own custom vertex attributes? I know I can pass extra per vertex data inside the uv channels. But I want to create per instance data and set it as a separate stream to be interpreted in the Input Assembler so I can read my instance data from there instead a Cbuffer or a structured buffer for GPU instancing.
     
  2. aras-p

    aras-p

    Joined:
    Feb 17, 2022
    Posts:
    75
    No, the Mesh API additions around Unity 2020 do not allow specifying per-instance or other instancing related data (step rate etc.). It's more or less "just" being able to operate on index and vertex buffer(s) directly as "it's just memory", without having to go through a bunch of array copies. And also ability to specify vertex formats in a more flexible way than what was previously possible (which was: everything is a float, except vertex colors could be bytes).
     
    VictorKs likes this.
  3. VictorKs

    VictorKs

    Joined:
    Jun 2, 2013
    Posts:
    242
    Thanks a lot for replying I thought my post would go unnoticed! I guess custom Input Assembler layouts is low level for a game engine. Anyway tbh I don't really need per instance data VertexBuffers, its just that the new API reminded me a lot of DX programming.

    Also it may be a little out of topic but since many of my posts go unnoticed I'd like to take the opportunity to ask you about DrawMeshInstanced() and DrawMeshInstancedProcedural() methods. In my experience DrawMeshInstanced() is Unitys pre-built Instancing option using CBuffer for per-instance model2world matrix. Thus we are limited to 1024 instances(at best).
    While DrawMeshInstancedProcedural is a more generic approach allowing us to setup our own procedure which is called to setup per instance data. Thus we can use structured buffers to bypass the cBuffer limits. But I believe both functions call DX11 DrawIndexedInstanced behind the hood. Or am I mistaken?? Btw thanks a lot for your time!