For example, if I use vertex shader like the following:
#version 400 core
uniform mat4 projM;
uniform mat4 viewM;
uniform mat4 modelM;
in vec4 in_Position;
out vec4 pass_position_model;
void main(void) {
gl_Position = projM * viewM * modelM * in_Position;
pass_position_model = modelM * in_Position;
}
Will it do projM * viewM * modelM
matrix multiplication for each vertex, or it it smart enough to calculate if once and do not recalculate until uniform variables are changed?
If it isn't "smart enough", then is there a way to optimize it other than computing all uniform-dependent values on CPU and send them as uniform variables to GPU?
Also I'm interested in solutions that can be ported to OpenGL ES 2.0 later without problems.