Implements shading types 4, 5 and 7