Added stencil shifting code to gamma.

This is lightly tested and not verified to be correct.