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!