PDA

View Full Version : Assign to uniform from shader



Kopelrativ
04-11-2011, 08:52 PM
It doesn't seem to be allowed to assign to uniform parameters from inside the shader program? It would be a great way to help debugging.

Alfonse Reinheart
04-11-2011, 09:50 PM
It doesn't seem to be allowed to assign to uniform parameters from inside the shader program?

Of course not. Uniforms, by definition, are uniform. Constant. They do not change across multiple executions of a shader. If you could set them from within a shader, they wouldn't be uniform anymore.

You can initialize uniforms to a value, but they will only retain that value so long as you don't set that uniform on that program from OpenGL. If you do, then the initialized value is lost.