Hello everyone,
I’m encountering a strange issue with a loop in my Niagara HLSL Expression, and I’m hoping someone can help me understand what’s going wrong.
I created a Dynamic Input that is used to set a parameter in the Particle Update section of my FX.
Here’s a simplified version of the code:
Example 1
int Num;
InteractionIndices.Length(Num); // Out 6
ReturnValue = Num;
// Here, ReturnValue is equal to 6, which is expected because InteractionIndices is an Array of 6 int32.
Example 2
int Num;
InteractionIndices.Length(Num); // Out 6
ReturnValue = -1;
for (int k = 0; k < 6; ++k)
{
ReturnValue = k;
}
// Here, ReturnValue is equal to 5, which is expected.
Example 3
int Num;
InteractionIndices.Length(Num); // Out 6
ReturnValue = -1;
for (int k = 0; k < Num; ++k)
{
ReturnValue = k;
}
// Here, ReturnValue is equal to 0, but I expected it to be 5.
In the third example, Num
is supposed to be 6, just like in the first example. However, ReturnValue
ends up being 0 instead of 5, which is confusing.
This happens only when the simulation target is set to CPU.
I also tried to set the Num
value with a Length Node, an input parameter from Map Get, and a Make Int32. Only the Make Int32 Node works; for the others, I get the same problem.
I feel like Niagara HLSL with CPU does not support dynamic parameters in loop behavior. I searched the documentation but did not find any specific information specific to Niagara HLSL.
Any help would be greatly appreciated!
Thank you.