0 like 0 dislike
169 views

Hi

I keep getting an error: L_7 parse error after function, when I try to use a single line if statement. It is in the form:

if (Life < dt * 3)
    Color = float4 (0.0,0.0,0.0,0.5);

Where Color is tabbed in. Is there something that I am missing? If I comment out these lines, it works properly .
http://imgur.com/a/ZJZVA
Thanks!

by gbernal (340 points)

1 Answer

0 like 0 dislike

Hi gbernal,

There are no 'if' statements in popcornfx scripts. (There once were, and might be once more after version 2.0 is released, but currently, they aren't available)

to do the equivalent of 'if' statements, you'll have to use the 'select' or 'iif' builtins ("iif" stands for "immediate if" or "inline if"):

if (Life < dt * 3)
    Color = float4(0,0,0,0.5);
else
    Color = float4(1);

becomes:

Color = iif(Life < dt * 3, float4(0,0,0,0.5), float4(1));

or:

Color = select(float4(1), float4(0,0,0,0.5), Life < dt * 3);

Compared to real 'if' statements, in addition to the visual syntactic difference, this has the disasvantage of having to always compute both statements, then select which one it should use based on the condition.

so you won't be able to use selects or iifs to avoid performing expensive computations such as scene intersections or spatial layers lookups.

by Julien (32.6k points)
...