Sign in to follow this  
derodo

Uniforms, varyings, GL state and...globals?

Recommended Posts

derodo    122
Hi all, As far as I know, with GLSL you can use uniforms, varyings, and you got access to all usefull GL state variables (matrix, planes, lights, etc) but... Is there any kind of "global" variables shared by all program objects, apart from the GL states? I mean, if you want to use a variable "time" in some shaders (for doing some kind of time dependent computation), and you define it as a "uniform float", then you will need to update it one time per each shader using it for every frame. So I'm just wondering if I missed some point in the GL Shading Language spec, and there is any way to set a common variable than can be read by all shaders, without having to programataically set it for each one ¿do you know what I mean? So far, the only way I can think of doing it is by setting over an unused GL state variable (the X component of some user clip plane, for example), and program the shaders asuming that state variable will actaually contain a "time" value... Any hints?

Share this post


Link to post
Share on other sites
mod42    134
Hi

I dont know any direct way to do this (besides on some self written shader container object which handles that for you) in any other way then using a GL state for that purpose.

mod42

Share this post


Link to post
Share on other sites

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