Clamp when writing to the buffer, insteadof at the end of the shade() function