Setting an attt/unif that doesn´t exist

Hi all. I have an application that loads some shaders and tries to set values for some uniforms and attributes that may not exist in the shader. For example, the application tries to set the uniform called “gloss” but the shader loaded doesn´t contain any “gloss” uniform declared. The question is if this hurts the performance? If does, what about if it is only tried to set when loading and not in every frame (for example, an uniform called “opacity” could be set at every frame trying to do a blink effect)?

Thanks!

Attributes and uniforms have locations - you can query for these.
If the uniform or attibute does not exist, then the glGetAttribLocation will return -1. Your program code should be detecting this and only uploading new uniform data with locations >=0.
Setting the uniform value at shader load/compile time is useful for ‘static’ uniforms and means you don’t have to alter the value every frame.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.