Primemaster
Primemaster

Reputation: 312

GLSL Uniform evaluation

If in a vertex shader there is:

#version 450 core
uniform bool v1;

void main()
{
    if(v1 == true)
    {
        //do something
    }
}

Since Uniform variables are constant throughout the shader run, how many times will the if be evaluated per frame? One? Or one per vertex (since we are in the vs)?

Upvotes: 0

Views: 113

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473272

Either it will be evaluated once per vertex, or the system will recompile the shader every time you change that uniform (or maybe just have 2 forms of the shader). You should prefer the former to the latter.

Upvotes: 1

Related Questions