simplify tonemapping code