I just started working with computer shaders in Unity Engine and right now I have only this method inside my compute shader:
int Iterations = 1000;
[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
[unroll(1000)] for (int i = 0; i < Iterations; i++)
{
Result[id.xy] = float4(1, 0, 0, 1.0);
return;
}
Result[id.xy] = float4(0, 0, 1, 1.0);
}
I expected the output texture to be completely red but it is blue. However, as far as my understanding goes, that would mean that the for loop is not executed or that the return statement does not work. But both things don't seem to make sense to me, so can someone explain to me what is going on here?