The potential of industrial applications for microalgae has motivated their recent fast development. Their growth dynamics depends on different factors that must be optimized. Since they get their energy from photosynthesis, light is a key factor that strongly influences their productivity. Light is absorbed and scattered in the liquid medium, and irradiance exponentially decreases towards the darkest part of the photobioreactor at a rate non-linearly depending on the biomass concentration. Maximizing productivity is then a tricky problem, especially when the growth rate is inhibited by an excess of light. Productivity optimization turns out to be highly dependent on how light is distributed along the reactor, and is therefore related to the extinction rate and the background turbidity. We propose a theoretical analysis of this problem, by introducing the concept of optical depth productivity for systems where background turbidity must be accounted for. A global optimum maximizing productivity is proposed, extending the concept of the compensation condition, consisting in compensating the algal growth rate at the bottom of the reactor by the respiration. This condition can drive the optimization of the surface biomass productivity depending on the minimum reachable depth. We develop a nonlinear controller and prove the global asymptotic stability of the biomass concentration towards the desired optimal value.