M-Array pattern encoding is widely used in structured light for 3D reconstruction due to its single projection and single imaging characteristics. The robustness of M-Array in 3D reconstruction can be assessed by the accuracy of the global positioning of the code-word and the density of the decodable feature points. This paper proposes a pattern encoding method of robust M-Array based on texture constraints. M-Arrays are formed by matching and splicing candidate sub-windows, which are composed of symbols obtained from an M-Sequence one by one. To construct an M-Array with more texture information, both the number of edges and the maximum rectangular area within the sub-window are constrained. A novel three-level backtracking mechanism reduces the time complexity. Four indicators are introduced to evaluate the robustness of the M-Array and used to compare the proposed method with existing methods. The results show that the proposed method has low similarity between adjacent sub-windows and high uniformity of symbol distribution globally, indicating better accuracy of sub-window decoding. A 3D reconstruction experiment in the actual scenes proves that the point cloud density and accuracy obtained by solving the M-Array pattern constructed by the method proposed are better.