How can i calculate modulo in sparksl code?

hi dear friends
anybody knows how to calculate modulo in sparksl code? it’s giving me this error → “error: Operator ‘%’ is not allowed”

I think it’s because Spark uses an older version of the glsl spec that doesn’t support the % operator. Instead, you can use the mod function, e.g. mod(x, y);

https://registry.khronos.org/OpenGL-Refpages/gl4/html/mod.xhtml

Simple VCR .sca (2.1 KB)
even if i’m using “mod” it’s still giving me syntax error. can you please take a look at this shader code?
line 53

The problem wasn’t with mod, but with some type conversions between int and float (e.g. you can’t divide and int by a float). I think int was being used as a way to floor the value, but you can just use floor instead.

Separating the code into smaller chunks can make it easier to understand where the problem is. This is what I ended up with:

    float mx = floor(fragCoord.y + (iTime * r * 1000.));
    float my = floor(ival + line_intensity) / ival;
    float on = mod(mx, my);

Simple VCR .sca (2.2 KB)

1 Like

Thank you so much
You’re a lifesaver :heart_eyes::+1: