1
votes

Newer versions of GLSL reduce the amount of standard, built-in attributes and uniforms, e.g. gl_Color and gl_ModelViewMatrix are not in GLES 2.0.

Is it OK to override these names and redefine them in a shader to be of another variable type? Would declaring your own gl_ModelViewMatrix uniform when running on an early GLSL version work if you set them yourself?

In early GLSL gl_Color can be per-vertex or for a whole call, depending on if the client called glColor() or glColorPointer() - can you set an attribute once so it in effect becomes a uniform? Or how to deal with this ambiguity?

(This is all in a quest to make shaders that work across a range of targets with some simple find-replace scripts at load-time)

2

2 Answers

2
votes

You can't override them and you can't use variables-names with the beginning "gl_"( A paper told me this ). Changing build-in types/variables is afik not possible at all.

1
votes

Your best bet, if you want to easily support multiple versions of GLSL, is to use macros. For example, you could define your input color as:

#ifndef color
in vec4 color;
#endif

Then, to run on an older version of GLSL, you prepend the shader with #define color gl_Color