I'm trying to create an übershader to represent some wavefront data which might or might not contain some properties, e.g.:
- one or more objects might contain
uv
coordinates and a texture - one or more objects might contain normal mapping for each vertex
- one or more materials might be rendered with a different illumination type, and contain a texture for bump mapping
and so on.
Now, it might or might not be a good idea to create an übershader for this (I'm experimenting), but I'm facing the problem that some attributes are specified and some are not (missing uniforms, like texture samplers not set are handled with boolean uniforms that turn on and off the sampling feature).
What does happen in a GLSL v 3.00 when an attribute is both not assigned (which means no glEnableVertexAttribArray
, for instance, but also no buffer bound/anything) and not used in the GLSL program for reading (e.g. I'll use a uniform boolean
to turn texture lookup off, when UV coordinates are missing, though I might still interpolate the coordinates as in/out between vertex and fragment shaders, like this:
// Vertex shader
in vec3 vn;
out vec3 fvn;
[...]
fvn = vn;
...)?
Is this a legal use of the glsl, or will I incur in weird compatibility problems (I'm developing for mobile, as the OpenGL ES3.0 tag implies)?
I'm looking for either first hand experiences or an authoritative source,
Thank you!