I've been following a guide to learn OpenGL, and I'm now learning how to do post-processing.In particular, I'm trying to apply a blur to my rendering through the following kernel:$\frac{\begin{bmatrix}1&2&1\\2&4&2\\1&2&1\end{bmatrix}}{16}$The problem I'm encountering is that whenever I try to access a float array's member through the [] operator giving it an int variable as parameter, it returns 0.0.Here's my fragment shader:#version 410 corein vec2 txcoords;  // Texture coordinatesout vec4 color;uniform sampler2D tx;const float offset = 1.0 / 300.0;void main() {    vec2 offsets[9] = vec2[](        vec2(-offset,    offset),        vec2( 0.0,       offset),        vec2( offset,    offset),        vec2(-offset,    0.0),        vec2( 0.0,       0.0),        vec2( offset,    0.0),        vec2(-offset,   -offset),        vec2( 0.0,      -offset),        vec2( offset,   -offset)    );    const float kernel[9] = float[9](        1.0 / 16, 2.0 / 16, 1.0 / 16,        2.0 / 16, 4.0 / 16, 2.0 / 16,        1.0 / 16, 2.0 / 16, 1.0 / 16    );    vec3 sampleTex[9];    vec3 final = vec3(0.0);    for (int i = 0; i < 9; i++) {        sampleTex[i] = vec3(texture(tx, txcoords.st + offsets[i]));    }    for (int i = 0; i < 9; i++) {        final += sampleTex[i] * kernel[i];    }    color = vec4(final, 1.0);}This code doesn't work(whole screen renders black), but if I change it tofinal += sampleTex[i] * kernel[0];then my scene is rendered correctly, but, of course, without any blur, just a bit darker than normal.It also doesn't just work with kernel[0], but with any number ([1], [2], etc.)If instead I change it to final += sampleTex[i] * (kernel[i] + 0.05);then it renders exactly the same as withfinal += sampleTex[i] * 0.05;And that's why I ended up suspecting that it's the [i] part that just won't work, for whatever reason.Does anyone have any idea as to why this is happening? I also tried with different shader versions (330, 400, etc.) but they all give the same result.Thanks for your time!
GLSL broken access operator
opengl;glsl