I have been trying to cache binary shader programs in my game and load them accordingly using "glGetProgramBinaryOES" and "glProgramBinaryOES" respectively.

I was successfully able to cache and load the programs but there is one problem that can be seen in some of the shaders. The problem is that SOME pixels of the object that uses that shader appear black / white and keep flickering.

These are heavy shaders and I cannot skip their caching. Any help ?


  1. I compile and store the shaders on the device itself. So device/GPU dependency is taken care of.
  2. I recompile the shaders on any new OS DLC, so software update is taken care of.

The white spots in the image below show the glitch that i am encountering.

enter image description here

  • \$\begingroup\$ Are you using normal maps? If so, have you checked them for bake errors? The only other suggestion I can think of is to comment out all but the basics needed to get the shader running and then start un-commenting lines until you find the problem. \$\endgroup\$ Jun 28, 2014 at 22:39

2 Answers 2


It is possible that your issue may be due to the lack of use of the invariant qualifier in your shaders. Quote from the book OpenGL ES 2.0 Programming Guide:

There is a keyword introduced in the OpenGL ES Shading Language invariant that can be applied to any varying output of a vertex shader... The issue is that shaders are compiled and the compiler might perform optimizations that cause instructions to be reordered. This reordering means that equivalent calculations between two shaders are not guaranteed to produce exactly identical results. This can be an issue in particular for multipass shader effects where the same object is being drawn on top of itself using alpha blending. If the precision of the values used to compute the output position are not exactly identical, then artifacts can exist due to the precision differences.

So I'd recommend that you check your use of invariant and add it to gl_Position and others if not already doing this.

You can make gl_Position invariant with:

invariant gl_Position;

And any other user declared variable:

varying vec2 texCoord;
invariant texCoord;

Or you can even enable it globally with

#pragma STDGL invariant(all)

Though this last way may not be widely supported.


Have you verified that all variables used are initialed before using them? Using a variable that you have not yet assigned values to can cause flickering. For instance, if you have a variable that is created like this:

vec4 secondaryColor; 
vec4 color = vec4(0.1, 0.1, 0.1, 1.0); 
void main()                                                                                
    color += secondaryColor; // and then try to use it like this 

The variable secondaryColor will only contain garbage data unless you give it some value before adding it to color. This is the first thing I look for when I see something like this happen.

Duplicate geometry could cause flickering because of z-fighting.

If the camera clipping is spread out too far:

near = 0.001
far  = 10000000.00

this is also likely to cause z-fighting.

So far as pre-compiled shaders go, I have no experience with them. As far as I understand it, they prevent you from taking advantage of optimized driver updates since they were compiled with older drivers. That is something I read in an older nVidia document. It recommended that we don't use them unless there is a very good reason for doing so.

Then there are some other theoretical problems. You might not be able to take advantage of bug fixes.

I also imagine these shaders compiled for one GPU could have problems if you run them on GPUs made by a different manufacturer... Unless I misunderstand what you are doing with this.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .