Global variables in GLSL?

0

Is there any way to declare variables so they can be used in other files, with the same value as the original? I've already tried to use varying but it only works for the file .vsh and .fsh of the same part. Example:

In the composite.vsh file:

bool isNight = false;
void main() {
    isNight = true;
}

Alas, I use this same variable in the skybasic.vsh file:

if (isNight) {
    //está noite
}

without having to "recreate" all this variable again. How can I do this?

    
asked by anonymous 15.07.2016 / 04:50

1 answer

1

I'm not sure what you're trying to do. Variables of type varying are used to pass data from vertex shader to fragment shader.

There are variables of type attribute that you send the values through your application, so from the application code, you can send as many shaders as you want.

There are also uniform , which are sent from the application, the difference with attribute is that uniform can not be modified after they are in the shader. I think your case is uniform

    
28.09.2016 / 21:31