Moved fog application to the correct place

The fog was applied before gamma encoding, resulting in incorrect blending with fog color other than white. To see the difference, set the background skycolor and fog color to the same non-white color. One should expect the objects to dissapear in the sky as they get far.