I was reading the GLSL 1.20 spec for clarification on varying defaults and noticed that 4.3.6 states:
Reading a varying variable in a vertex shader returns undefined values if it is read before being written.
That statement seems to be limited to the vertex shader only. There is no similar clarification given for the fragment shader or other stages suggesting that reading an unassigned varying variable is legal outside of the vertex shader.
It also states the following in the same section:
Only those varying variables used (i.e. read) in the fragment shader executable must be written to by the vertex shader …
Is it correct to assume using a varying in the fragment shader that hasn’t been written to by the vertex shader is a potential compile-time error, or will it just result in undefined values?
I am able to compile without error using an Nvidia card but can’t say for other vendors.
#version 120
attribute vec4 position;
void main() {
gl_Position = position;
}
#version 120
varying vec4 ignored;
void main() {
gl_FragColor = ignored;
}