I am writing a 3D graphics engine.
I’ve heard that it is bad to use too much uniform variables in your shader program because it can cause slowdown.
On the other side, some say that re-using some built-in variables like gl_TextureMatrix is kind of bad practice.
How should I organize creating my shader programs ?
Should I write plenty of uniforms for each mechanism or can I rely on those built-in variables ?
For example, should I use built-in gl_LightSource or define own uniform array with light source informations, so I can have more lights on my scene? I also know about deferred rendering techniques but I want to do basic multiple lights first.
Or maybe, which built-in variables are ‘OK’ to reuse?
What are (dis)advantages of each of these practices?
I’ve never heard that uniforms can slowdown the shader, they are like compile time constants (or should be).
About using built-in variables, it’s not recommended to use them, because they are deprecated in OpenGL 3.0 and with the OpenGL Core profile, they are not available. They were removed for sake of programmability. You can define your own variables for anything you want and that is fine.
So, it’s just a matter of programmability, if you are learning and want to use them, it’s also fine.