Shape formation mechanism plays an essential role in many natural processes, involving the formation and evolution of living or non-living structures, and shows potential applications in many emerging domains. In existing research and practice, there still lacks a shape formation mechanism that manifests efficiency, scalability, and stability at the same time. Inspired by phototaxis observed in nature, we propose a self-organized approach for the massive formation of connected shapes in grid environments. The key component of this approach is an artificial light field superimposed on a grid environment, which is determined by the positions of all agents and at the same time drives all agents to change their positions, forming a dynamic mutual feedback process. To evaluate the effectiveness of this approach, we conduct a set of simulations, involving <inline-formula> <tex-math notation="LaTeX">$156$</tex-math> </inline-formula> shapes from <inline-formula> <tex-math notation="LaTeX">$16$</tex-math> </inline-formula> categories, comparing with four baseline methods. The results show that: (1) our approach outperforms the three semi-/decentralized non-optimal baselines in efficiency, scalability, and stability; (2) compared to the centralized optimal baseline, our approach exhibits considerable decreases in the absolute completion time on diverse shape formation tasks, indicating a better efficiency and scalability of our approach. <i>Note to Practitioners</i>—In nature, shape formation phenomena emerge from collective behaviors of swarms based on chemical or physical signals. These natural phenomena provide valuable insights to build large-scale multi-agent collaboration systems using software-defined digital signals. This work proposes a phototaxis-inspired computational approach for shape formation that enables a massive swarm of agents to form arbitrary connected shapes in grid environments based on a digital signal called artificial light field. The significance of this work is twofold: 1. it could contribute to a deep understanding of shape formation mechanisms; 2. it would motivate new research on advanced multi-agent algorithms, massive collaboration mechanisms, and artificial collective intelligence systems and facilitate their practical applications. Specifically, the shape formation mechanism has promising applications, including smart warehouses, autonomous cooperation of UAVs, and intelligent transportation systems. A possible realistic application scenario of our method in intelligent transportation systems is bike sharing systems, in which the designated parking areas for shared bicycles near the work area are often overcrowded and difficult to park in during the morning peak period, so dynamic parking route guidance for users is required. Our method can directly apply to this scenario by utilizing the light field to represent the parking state of nearby bicycles and guiding the moving direction of each user.