# Get VertexSize of Instance in VertexShader

I'm using Unitys DrawProceduralIndirect function to directly render the content of a ComputeShader.

I setup the argumentBuffer for this function as follows:

    int[] csArgs = new int[] { ptsOnLine, 2, 0, 0};
argsBuffer = new ComputeBuffer(4, 4, ComputeBufferType.IndirectArguments);


So every instance consists of ptsOnLine (lets say 10) vertices.

My vertexShader then looks like this:

fsInput vert(uint id : SV_VertexID, uint instanceId : SV_InstanceId)
{
fsInput fsIn;
float3 worldPos = linePoints[id + (instanceId * 10)];
fsIn.pos = mul(UNITY_MATRIX_VP, float4(worldPos, 1.0f));
return fsIn;
}


The question is simple. My problem is: (instanceId * 10). Is there a built in variable telling me the length of one instance? I couldn't find anything. I mean, its in the argument buffer so it shouldn't be too much of a problem? I could forward this value from the compute buffer but thats ugly. :)

Help is much appreciated!

• Feels a bit redundant to pass it explicitly to the shader when it is already passed to DrawProceduralIndirect. Nevertheless, it seems that there is no built in variable, so this is the way to go. Thanks a lot! Aug 17 '17 at 14:27