Search Unity

Draw a part of a mesh

Discussion in 'General Graphics' started by lama89625, Oct 13, 2019.

  1. lama89625

    lama89625

    Joined:
    Feb 14, 2019
    Posts:
    14
    Hello everyone!

    I'm trying to find a way to draw a certain part of a mesh without actually creating / uploading a new mesh.
    Basically I would love to be able to specify an index offset and length (and change them at any time) while having the same vertex and index buffers.
    I guess it's possible to achieve using this as the example shows
    https://docs.unity3d.com/ScriptReference/Graphics.DrawMeshInstancedIndirect.html
    but in my case it seems sort of 'hacky' since I don't need it to be neither instanced nor indirect.

    Is there any other way to go anyone is aware of?
     
    Last edited: Oct 13, 2019
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    How about Graphics.DrawProcedural?
    https://docs.unity3d.com/ScriptReference/Graphics.DrawProcedural.html

    I think you could use a compute shader and use some logic there to decide what is going to be rendered and then use that DrawProcedural to output your data to a structured buffer. And then render the buffer contents.

    That way it would be at least rendered with lighting etc. so intergration with rest of the scene isn't that big issues like earlier when you had to pretty much (afaik) reconstruct the lighting functions etc. yourself.

    Keijiro has a good example that shows you pretty much every step you need (at least if your case happens to be similar.)
    https://github.com/keijiro/NoiseBall3
     
    lama89625 likes this.
  3. lama89625

    lama89625

    Joined:
    Feb 14, 2019
    Posts:
    14
    I might try doing something like this.
    Thanks!
     
    Olmi likes this.