In this paper, a novel shadow algorithm is innovatively proposed for the path planning problem in complex three-dimensional terrain environments, and successfully applied to path optimization in exploration, transportation, and other situations. The current mainstream path planning algorithms, such as \(\:A*,\) \(\:\text{D}\text{i}\text{j}\text{k}\text{s}\text{t}\text{r}\text{a}\) and their derived and improved versions, have many limitations in complex terrains, although they perform well in specific scenarios: \(\:A*\) algorithm relies on appropriate heuristic functions, and improper design or complex scenarios can easily lead to inefficiency in searching; \(\:\text{D}\text{i}\text{j}\text{k}\text{s}\text{t}\text{r}\text{a}\) algorithm’s computational volume soars with the rapid increase in map size, making it challenging to meet the demand for real-time planning; the traditional potential field method is prone to falling into local optimums and has insufficient optimization ability for global paths. The traditional potential field method is easy to fall into a local optimum and has insufficient optimization ability for the global path. The shadow algorithm proposed in this paper effectively overcomes the shortcomings of traditional algorithms by simulating the propagation characteristics of light in the terrain, combining dynamic detection point generation, multi-factor comprehensive evaluation, and other mechanisms. The algorithm constructs a comprehensive cost function with multi-dimensional factors such as terrain gradient, energy consumption, and goal orientation, which guides it to find the globally optimal path in complex terrain. In simulation experiments, the algorithm successfully plans a continuous smooth path from the lowest point to the highest point, showing superior global optimization ability, real-time and adaptability, providing an efficient and reliable solution for path planning under complex terrain, with important theoretical innovation and practical application value.