Sign in to follow this  

does GLSL shader keep uniform values?

This topic is 4201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I don't know how to explain it in one sentence so forgive me my little story: I am using one shader (GLSL but i don't know if that really matters) during my rendering, which is activated for some geometry and deactivated for the others during one rendering pass. Now I am wondering about the following: if I send some uniform values to the shader in the beginning of the rendering (while the shader is active), then deactivate the shader and the activate again, does this uniform variable still contain the value i set in the beginning. The thing is, at the moment it seems to me that it actually does in the application, while i was expecting to encounter some errors. The application is a huge thing and I am just one little programmer so it might be that I overlooked something. Maybe somone here knows how it is and can tell me ... thx rapunzel

Share this post


Link to post
Share on other sites
Yes, GLSL program do indeed maintain their uniform state between bindings, which means you should only be setting them when things change. This is important for things such as texture samplers as there is ALOT of validation work which occurs when you change the value of one.

Additional performance hint; unless you relink a shader the uniform locations will stay the same, as such when doing a lookup based on a name cache the results until a relink happens, this saves you having to query the object directly which is "slow".

GDC05 video and slide links in the FAQ go into this more iirc.

Share this post


Link to post
Share on other sites

This topic is 4201 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this