We will pick an object based on its color. If the object has shiny reflections or shadows, then the color throughout it will not be uniform. Therefore, to pick an object based on its color we need to make sure that the color is constant per object and that each object has a different color.
We achieve constant coloring by telling the fragment shader to use only the material diffuse property to set the ESSL
gl_FragColor variable. Here we are assuming that each object has a unique diffuse property.
When there are objects sharing the same diffuse color, then we need to create a new ESSL uniform to store the picking color and make it unique for every object that is rendered into the offscreen framebuffer. ...