This paper proposes an optimization framework for terrain large scale optical sensor placement to improve border protection. Compared to the often used, maximal coverage of an area approach, this method minimizes the undetected passages in the monitored area. Border protection is one of the most critical areas for sensor placement. Unlike traditional border protection solutions, we do not optimize for 2D but for 3D to prevent transit. Additionally, we consider both natural and built environmental coverings. The applied environmental model creates a highly inhomogeneous sensing area for sensors instead of the previously used homogeneous one. The detection of each sensor was provided by a line-of-sight model supplemented with inhomogeneous probabilities. The optimization was performed using a bacterial evolutionary algorithm. In addition to maximizing detection, minimizing the number of the applied sensors played a crucial role in design. These two cost components are built on each other hierarchically. The developed simulation framework based on ray tracing provided an excellent opportunity to optimize large areas. The presented simulation results prove the efficiency of this method. The results were evaluated by testing on a large number of intruders. Using sensors with different quantities and layouts in the tested 1×1×1 km environment, we reduced the probability of undetected intrusion to below 0.1% and increased the probability of acceptable classification to 99%.