Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Official SRPs and GPU instancing for skinned meshes?

Discussion in 'Graphics Experimental Previews' started by chiapet1021, Feb 12, 2018.

  1. chiapet1021

    chiapet1021

    Joined:
    Jun 5, 2013
    Posts:
    605
    I was wondering if either the LW or HD pipelines will have any enhancements to instancing--in particular, whether it will be possible to reap the benefits with skinned meshes. I'm definitely not a graphics programming guru in any sense of the word, so apologies if this is an infeasible ask to begin with. :)
     
  2. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    This would only be possible if they made all animation happen in the shader level. Not likely to come anytime soon.
     
  3. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    What I'd prefer is a real example of how to implement a shader that is compatible with Graphics.DrawProcedural() and has proper lighting/shadowing/lightmapping/GI/etc.....

    Basically what they did for the Job System RTS demo with 100k units. I'm pretty sure this must be fairly simple to do for someone who knows the render pipeline well, but for others there's a ton of poorly-documented stuff to figure out

    It is more efficient than instancing, and from there we could make our own single-draw-call skinned mesh crowd renderer
     
  4. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    What they did was not simple and it's very very specific to the project. Animation data was stored in 2d texture arrays then looked up and animated in the shader. This will not work for the general case at all :)
     
    twobob, PhilSA and Prodigga like this.
  5. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I understand that the management of the animation is extremely specific and not something unity should bother making a tutorial about, but I think an example of a hello-world standard pbr shader for DrawProceduralIndirect would be very helpful and simple to do (something just for non-animated meshes)

    I attempted using something like this in the past to make a fully destructible city (pre-fragmented meshes) of 200000 meshes drawn in a single draw call with DrawProceduralIndirect, and I was never able to figure out how to do proper lighting/shadows/GI for my shader (a vert/frag shader that uses SV_VertexID and StructuredBuffers of vertex pos/normal/etc for its data)

    But aside from the shading problem, this thing ran at 200 fps on a toaster, compared to about 15 fps when using regular mesh renderers. So I can definitely see value in educating people about the basics of this technique.

    Here's a sample of it with my ugly shading:
    https://i.gyazo.com/188a4fb5e504e0f4c93a95c6f5bb314b.mp4
     
    Last edited: Mar 1, 2018
    MadeFromPolygons and one_one like this.
  6. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
    I must agree with PhilSA, a simple DrawProceduralIndirect example in SRP would be great! (Custom animations are not important right now, just a rendered sphere with DrawProceduralIndirect with SRP would be awesome!)
     
    MadeFromPolygons likes this.
  7. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    Same, not sure why this hasnt been addressed up till now but would be great to have!
     
  8. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365
  9. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    365