Hello everyone, I have been having an issue with the modulo implementation in GLSL
I'm running version 4.5 Core and have the following problem:
Even though mod is defined as
x - y * floor(x/y)
(source: https://www.opengl.org/sdk/docs/man4/html/mod.xhtml) which, when you plot it for y = 3, looks like this:
I am running into an issue where the result of -1 % 3 is apparently not within the domain [0, 2].
To be precise, the reduced code causing the error message is this:
vec3 barycentric;
vec3 barycentric_verts_sequence[3] = vec3[](vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));
barycentric = barycentric_verts_sequence[-1 % 3];
The error reads: error C1068: array index out of bounds.
If shaders were easily debuggable, I probably wouldn't be asking this question, but since there's no way to step through the shader code while it's running, I was hoping that someone more experienced with GLSL could help me out!
Thanks in advance,
Marvin