I fully agree with all other replies and comments that rgba is definitely faster as it reduces the number of fetches from 16 to 4. You can even omit the per-element assignment:
//I also fixed the typo in Matric[i]es
m = texelFetch( projMatrices , ivec2( 0 , lightIndex ) , 0 );
m = texelFetch( projMatrices , ivec2( 1 , lightIndex ) , 0 );
m = ...
This question and its answer, actually answer my question. I had to read its answer carefully and find my mistake.
Now my fragment shader look like this:
const GLchar* fragmentSource = R"glsl(
#version 330 core
in vec2 TexCoord;
uniform sampler2D ourTexture;
#define PI 3.141592653589793238462f
#define TWO_PI 6....
GLSL does not support C++ style namespaces. You might want to do some regex magic before parsing the shader, replacing '::' with '_' or something. You might want to have a preprocessor of sorts - or just forget about it entirely.
As Olivier mentioned, it's not safe in general to apply algebraic optimizations to floating-point math, as floating point doesn't actually obey associativity rules due to roundoff error. $(a + b) - b$ will not be equal to $a$, if the intermediate result $(a + b)$ had to be rounded; nor will $a \cdot (b + c)$ be equal to $a \cdot b + a \cdot c$ in general, ...
The eye position (a vec3) was being bound to the wrong shader, resulting in the glUniform3 error when OpenGL (mesa) checked the validity of the uniforms. The error was due to a typo; I named my simple-mesh and animated-mesh shaders similar things.
glUniform3fv(mesh_shader.uniform("eye"), 1, &...
Yes, it is guaranteed by the GLSL language specifications (click me). Section "4.1.10. Implicit Conversions" says
In some situations, an expression and its type will be implicitly converted to a different type.
The spec shows all possible implicit conversions inside a table, also int -> float. It further says:
When an implicit conversion is done, it ...