"&" ">>" is not allowed

Does anybody know how to fix this ?

Screenshot_1

This is so weird that || OR operator is allowed but && operator is not allowed … like WHY?

& is not the same as &&

&: bitwise AND
&&: logical AND

Here are some fallback functions for bitwise AND and OR, but they are probably super inefficient compared to the native operators. In absence of bitwise operators in WebGL 1.0, I used these methods as substitute. · GitHub

For the bit shifting, I think you can convert to standard math operations.

“A bit shift is a multiplication or division by 2n”

1 Like

bro have you tried this before?
i’m getting Component type mismatch, expected ‘int’
or
Component type mismatch, expected ‘int’
errors
shader.sca (2.9 KB)

nested functions are also not allowed so how can we have a function inside another function?

You can pass in any number of arguments to a function, so you can un-nest the functions and pass in whatever they were accessing in the other function scope.

I’m not getting any component type mismatch errors. I can’t even drag that patch into the graph because it has errors. Maybe it’s because you have it in the graph when it shouldn’t be allowed?

i don’t really understand these equations. can you please do one for me as an example so i can learn and do rest of them?

I’m honestly not very familiar with bitwise operators but I think I managed a fallback for &1. It seems like it just flips the least significant digit, essentially making it an even/odd function.

// Hopefully does the same thing as &1 operation
// return 0 if even, return 1 if odd
ivec2 and1(ivec2 vec){
    float x = mod(float(vec.x), 2.);
    float y = mod(float(vec.y), 2.);
    return ivec2(x, y);
}

I don’t have any more context though. I’m not sure what this shader is supposed to be doing. I don’t think it’s working, but at least there are no errors.

spark-and1.arexport (30.9 KB)

1 Like

bro you’re a legend :+1: