Move shading logic into tracer function