Search Unity

Question DrawMeshInstancedIndirect with per instanced culled vertices

Discussion in 'Shaders' started by midramble, Jan 9, 2021.

  1. midramble

    midramble

    Joined:
    Jan 20, 2017
    Posts:
    9
    Is there a way to do this?

    For instance (excuse the pun), say you wanted to render hundreds of thousands of mannequins using the same mesh through instancing but you wanted them to randomly have parts missing and didn't care about back faces being culled? I first thought this would be doable through submeshing parts and, per instance through the a compute buffer, changing the submesh but submesh has to be defined in the draw call.

    I haven't been able to find any documentation about doing this in the render pipeline or even how drawmeshinstancedindirect actually works as that is abstracted. If vertexes/vertex groups can't be culled per instance before it hits the vertex shader, is it possible to cull these vertices in the vertex shader, even though that wouldn't be as performant?

    TLDR: Can you cull vertices in a vert shader and or can you cull vertex groups after instance call but before vert shader?

    Edit: Also does drawmeshinstancedindirect cache the mesh geometry? Meaning that I could solve this by just doing drawmeshinstancedindirect for each submesh using a compute buffer each, or would DMII send the mesh data for every draw call?
     
    Last edited: Jan 9, 2021