I have a vertex shader with attributes that may or may not be set in any given frame.
No no.:)
With attributes, it is not possible for an attribute to not be "set." Each vertex shader instance receives valid values ββfrom each declared attribute.
If the attribute array is not included glEnableVertexArray , then the default attribute will be passed (as indicated by glVertexAttrib and its default values).
In your case, you can:
- compile your shader in different versions with or without texture (conditional compilation is your friend, google for UberShader),
- use a single variable of type "useTexturing" to save on shader switches.
Choose one.
source share