title: GLSL multiple shaderprogram VS uniforms switches
body: <p>I'm working on a shader manager architecture and I have several questions for more advanced people.
  My current choice oppose two designs which are:</p>
  
  <p><br/><h2>1. Per material shader program</h2>
  => Create one shader program per material used in the program.</p>
  
  <h3>Potential cons:</h3>
  
  <ul>
  <li>Considering every object might have its own material, it involves a lot of glUseProgram calls.</li>
  <li>Implies the creation of a lot of shaderprogram objects.</li>
  <li>More complex architecture that #2.</li>
  </ul>
  
  <h3>Pros:</h3>
  
  <ul>
  <li>Shader code can be generated specifically for each "options" used in the material.</li>
  <li>If i'm not wrong, uniforms have to be set only one time (when the shaderprogram is created).</li>
  </ul>
  
  <p><br/><h2>2. Global shader programs</h2>
  => Create one shader program per shader functionality (lightning, reflection, parallax mapping...) and use configuration variables to enable or discard options depending on the material to render.</p>
  
  <h3>Potential cons:</h3>
  
  <ul>
  <li>Uniforms have to be changed many times per frame.</li>
  </ul>
  
  <h3>Pros:</h3>
  
  <ul>
  <li>Lower shader programs count.</li>
  <li>Less SP swich (glUseProgram).</li>
  </ul>
  
  <p><br/>You might notice that my current tendency is #1, but I wanted to know your opinion about it.</p>
  
  <ul>
  <li>Does initial uniforms setting offset the glUseProgram call overhead (I'm not especially speed freak) ?</li>
  <li>In the case #1, for any memory or performance consideration, should I call glLinkProgram only once when I create the SP, or I must unlink/link each time I call glUseProgram?</li>
  <li>Are there better solutions ?</li>
  </ul>
  
  <p>Thanks!</p>