Light optimization: using Matx for flow calculation