title: Adding Lighting to a ShaderMaterial in three.js
body: <p>I'd like to create a ShaderMaterial that has lighting like a MeshLambertMaterial. I've created a <a href="https://github.com/brianhoy/threejs-procedural-generation/blob/master/client/scripts/procedural-generation/Generator.ts#L199" rel="nofollow">vertex and fragment shader</a>, and included the uniforms from THREE.ShaderLib[ 'lambert' ].uniforms in the ShaderMaterial. </p>
  
  <p>Correct me if I'm wrong, but I believe the next step to add lighting would be to merge the <a href="https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl" rel="nofollow">fragment</a> and <a href="https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderLib/meshlambert_vert.glsl" rel="nofollow">vertex</a> shader code used in the MeshLambertMaterial with my custom shader code. </p>
  
  <p>Merging the vertex shader would be straightforward. However, in the fragment shader, how do I provide a base color (which will be generated by my shader code) for the code in meshlambert_frag.glsl to apply the lighting calculations? The fragment shader would probably look something like this:</p>
  
  <pre><code>// my custom shader code before the main function
  // meshlambert_frag.glsl shader code before the main function
  void main {
    vec4 myBaseColor ... // set by my custom fragment shader code
    // meshlambert_frag.glsl code in the main function would use myBaseColor as a base 
    // color for the lighting calculations before setting gl_FragColor
  }
  </code></pre>
  
  <p>Additionally, is copying such a large chunk of code (from the meshlambert shaders) bad practice in this case? What would be a better solution?</p>