So I’ve got a Sprite class, which uses a simple vertex format of position (x,y), colour (r, g, b, a) and texCoords (u, v).
There’s a corresponding ‘textured’ shader which has position, colour and texCoord attributes in it’s vertex shader. So far so normal, everything works fine.
The problem is when I want to swap in an alternate texture. That one only uses position and texCoord, and ignores colour. For compatibility, the vertex shader still has a colour attribute, it’s just unused. However some drivers (hello nVidia!) will decide the ‘colour’ attribute is unused, and optimise it out. That means my code now crashes because the shader doesn’t actually expose the interface the source code looks like it does.
Does anyone know how to force a shader attribute to be included (ie. not optimised out)? Or any other alternate solutions to this?