title: OpenGL ES 2.0 Shader best practices
body: <p>I've been searching for examples of shaders in OpenGL and I've seen some varying styles. Some shaders specifically use the built in types (ie. gl_Vertex) to transfer data to and from the application code and the shader.</p>
  
  <p>Some shaders use the varying types to transfer data from vertex to fragment shader instead of gl_Position and gl_FragColor.</p>
  
  <p>Some shaders use the prefixes 'in' and 'out' to specify data transfer:</p>
  
  <pre><code>in vec3 vertex;
  
  void main() {
      gl_Position = projection_matrix * modelview_matrix * vec4(vertex, 1.0);
  }
  </code></pre>
  
  <p>... while others use attributes:</p>
  
  <pre><code>attribute vec4 vertex_attrib;
  attribute vec4 tex_coord_attrib;
  attribute vec4 color_attrib;
  uniform mat4 mvp_matrix;
  uniform mat4 texture_matrix;
  varying vec4 frag_color;
  varying vec2 tex_coord;
  
  void main(void)
  {
    gl_Position = mvp_matrix * vertex_attrib;
    vec4 transformed_tex_coord = texture_matrix * tex_coord_attrib;
    tex_coord = transformed_tex_coord.st / transformed_tex_coord.q;
    frag_color = color_attrib;
  }
  </code></pre>
  
  <p>My question is, what is the preferred way in GLES 2.0 to write shaders? Is there a best practices guide? Can someone provide an example of a vertex &amp; fragment shader that is a shining example of 'what to do'??</p>
  
  <p>Thanks.</p>