Unused Varying Variables in Fragment Shader GLSL - Can they hurt Perf
<p>What happens to the unused varying variables in GLSL
GPU's have inter shader buffers which would get populated with these values but since fragment shader is not using it , Wouldnt that be unnesscary computation which was being done in vertex shader (per vertex) &amp; then dropped since it's not used in fragment shader.</p>

<ol>
<li>Can GLSL compilers optimize these kind of wrong practices ?</li>
<li>If NOT , Would there be any performance improvement if these varying can   completely be removed from vertex shader from below exapmle ?</li>
</ol>

<p>Note : I havent written this shader - I have come across this shader while profiling &amp; debugging an GL app , So was curious to know if these could be causing any perf. issues or compiler would have optimized it - If not used in FS.</p>

<p>Example: </p>

<p>Vertex Shader</p>

<pre><code>attribute vec3 Normal;
attribute vec4 Vertex;
uniform mat3 NormalMatrix;
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelViewMatrix;
precision mediump float;
**varying vec3 N;**
**varying vec3 v;**
varying vec2 texCor;
void main(void)
{
    v = vec3(ModelViewMatrix * Vertex);
    N = normalize(NormalMatrix * Normal);
    gl_Position = ModelViewProjectionMatrix * Vertex;
    texCor = MultiTexCoord0.xy;
}
</code></pre>

<p>Fragment Shader</p>

<pre><code>precision mediump float;
uniform sampler2D data;
**varying vec3 N;**
**varying vec3 v;**
varying vec2 texCor;
void main (void)
{
    vec2 TexCoord = texCor;
    vec4 RGB      = texture2D( data, TexCoord );
    gl_FragColor = vec4(0.0, 0.0, 0.0 , RGB.r);
}
</code></pre>