Lately, I have been trying to build a Instancing Indirect system for HDRP. Despite the difficulties of working with shader code in SRP, I managed to draw whatever mesh I want.
The problem is: only one instance is drawn. (however, my suspect is that all the instances are drawing in the same position).
Before moving to use Structured buffers to set the positions, I use a simple hack of setting the instance position to (InstanceID, 0, 0), to give a little offset between them.
To access the instanceID, have:
// Vertex Graph Inputs
struct VertexDescriptionInputs
{
uint instanceID : SV_InstanceID;
float3 ObjectSpaceNormal; // optional
float3 ObjectSpaceTangent; // optional
float3 AbsoluteWorldSpacePosition; // optional
};
(Note this is a Shadergraph generated code)
Still, only one instance is drawn.
Later, I figured that my shaderCode is missing #define UNITY_INSTANCING_ENABLED. I turn it on and… nothing draws at all.
(yes, I have #pragma multi_compile_instancing)
I have found in some places of the code things like instanceID : INSTANCEID_SEMANTIC;, but I tried to use those and still, the same result.
My suspect is that, enabling instancing, something is being redefined and wrecks everything.
I have searched the web, and found that everyone uses different approaches.
Can anyone tell me how this works, and how I get out of this mess?