Bitwise AND operator in shaders

mbeytekin

Member
How can I calculate this in GM2 fragment shader;
m[(k+4)&7] += vec4(c1 * wk, wk);
s[(k+4)&7] += cc1 * wk;

(k+4)&7 gives a syntax error in GM2.. I found this code from shadertoy and it works there...

 

GMWolf

aka fel666
What syntax error do you get?
Perhaps try making your bitwise operands unsigned integers. Some drivers don't like signed bitwise logic.
 

sp202

Member
GM's shaders don't support bitwise operators, you'll need to do them manually by using multiplication/division.
 

mbeytekin

Member
I use like that;

m[int(mod((float(k)+4.),7.))] += vec4(c1 * wk, wk);
s[int(mod((float(k)+4.),7.))] += cc1 * wk;


I guess it's working now. :) Thank you..
 

GMWolf

aka fel666
GM's shaders don't support bitwise operators, you'll need to do them manually by using multiplication/division.
Really? Even if you write them in GLSL /not es or HLSL? Damn, what hardware level does GM target? Zx spectrum?
 

sp202

Member
No idea about whether GLSL/HLSL support them, depends on which versions GM uses. Not sure why Yoyo is using such an old version of GLSL ES, I'm sure they'll cite compatibility, but even so.
 
Top