Search Unity

Question URP shader with instancing

Discussion in 'Universal Render Pipeline' started by Tony_Max, Dec 4, 2021.

  1. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    352
    What am i trying to achieve: i write sprite render system with calling DrawMeshInstanced and for now i want to pass ComputeBuffers with random colors to shader.

    Problem: i've seen at least 3 ways to access to instanceID, and i can't figure out what of those is compatible with URP and what should i use with MPB.SetBuffer(int propID, ComputeBuffer colorBuffer)
    • through instancing_options procedural:setup
    • through structs + unity's macro which will initialize it with ID
    • through explicit SV_instanceID parameter in vertex shader)
    What i have: sprites renderings always with same color no matter what solution was picked (GPU Instancing Enabled toggle ON in material inspector), but in some cases they can be rendered at the same position like it happens with DrawMeshInstancedIndirect, where we need to handle positioning in shader through position buffer. Is it even possible to use DrawMeshInstanced and still pass any ComputeBuffer?
     
    thebarryman likes this.