With regard to the default fragment shader output:
There is no default and the result is undefined if you don't set one. See other answers.
I notice you have a texture, and sampling an 'unbound'/incomplete texture is different [1][2]. There is a default, but in practice I would not rely on this for all drivers!:
If a fragment shader uses a sampler which associated texture object is
not complete, as defined in section 3.8.10, the texture image unit will
return (R, G, B, A) = (0, 0, 0, 1). [↱]
There's also a uniform value which may not be set either. These remain constant for the entire draw call, and like samplers, also have a default (although this is more of an "initial" value).
As a result of a successful link operation, all active user-defined uniform variables belonging to program will be initialized to 0 [↱]
But what actually happens when you don't set a fragment colour?
Being undefined in the spec means (0, 0, 0, 1)
is a valid value and may in fact be the one you get. If a GL implementation (such as the one Nvidia or ATI provide with their driver + hardware) were to make this the consistent returned value, the generated shader code needs to set a default value or catch the case when you don't set one. This just adds overhead. It's faster to do nothing instead.
The shader must still return a value though, and what ever value is in the register/s for your fragment shader thread gets returned. This is uninitialized data (from the point of view of your shader program). Just like uninitialized memory in a CPU program, the value could be anything, generally depending on what was there beforehand. It's not uncommon for this to be all zeroes, or even something pretty consistent depending on the previous task the GPU was doing (i.e. another shader you run). Although I've found uninitialized values in the fragment shader quite commonly presents as flickering and can make patterns like this:
outputColor.rgb = frontColor.rgb + backgroundColor * frontColor.a;
– Richard VineybackgroundColor
as avec4
. You can't dovec4 + vec3
directly like that. – Richard Viney