## 2 Methods  
### Diffraction Grating Ray Tracing  
We propose a diffraction grating ray tracing model to characterize the far-field diffraction behavior of one-dimensional and two-dimensional periodic gratings under both normal and oblique incidence conditions. This model is employed to determine the initial architecture of the diffraction waveguide system. When a plane wave undergoes modulation by a grating periodic structure at a flat interface, its reflected and transmitted waves will change accordingly, as observed by its wave vector components along the flat interface on the transmitted, reflected, and incident sides, plus varying multiples of the grating vector \(\vec{K}_{\parallel}\), expressed as \(\vec{K}_{\parallel}=\vec{K}_{inc,\parallel}+m\vec{K}_{\parallel}\), where m denotes the diffraction order. In the vector circular diagram, the incident wave vector is \(\vec{k}_{inc}\) and its magnitude is \(k_{0}=2\pi n_{0}/\lambda_{0}\), where \(\lambda_{0}\) is the wavelength of the plane wave in vacuum and \(n_{0}\) represents the refractive index of the medium on the incident side. At this moment, the parallel components of plane waves of different orders on the transmitted side all differ from those of the incident plane wave by an integer multiple of the parallel components of the grating vector. First, the incident point is taken as the starting point for the transmitted wave vector and a circle is drawn with a radius of \(R=2\pi n_{1}/\lambda_{0}\). According to the dispersion relation:  
\[n^{2}k_{0}^{2}=k_{\parallel}^{2}+k_{z}^{2}\,. \tag{1}\]  
The endpoint of the transmitted wave vector must fall on the semi-circular arc that has been drawn. As shown in Figure 1, for a one-dimensional grating with normal incidence of the k-vector, the tracing process of the light ray can be described as follows:  
1. The incident wave vector determined by the wavelength and direction of the incident light is \(\vec{k}_{inc}\) as in Figure 1.
2. A semicircle of radius \(|\vec{k}_{inc}|\) and \(|\vec{k}_{inc}|/n_{1}\) is drawn, with the intersection point between \(\vec{k}_{inc}\) and the plane of the grating as the center, as shown by the blue semicircles in Figure 1.
3. Based on symmetry, the zero-order reflection wavevector \(\vec{k}_{ref,0}\) is drawn, starting from the incident wavevector's intersection point. A dotted line is drawn passing through the point of intersection between \(\vec{k}_{ref,0}\) and the blue semicircle, perpendicular to the plane of the grating. The point at which this dotted line intersects the grating plane is determined. This intersection point is used as a base point to divide the grating plane into sections of length \(|\vec{K}|\). Dotted lines are drawn perpendicular to the grating plane through each section's dividing point. 4. The dotted line intersects with the reflection and transmission side semicircles at the diffracted wavevectors \(\vec{k}_{ref,-2}\), \(\vec{k}_{ref,-1}\), \(\vec{k}_{ref,+1}\), \(\vec{k}_{trans,-3}\), \(\vec{k}_{trans,-2}\), \(\vec{k}_{trans,-1}\), \(\vec{k}_{trans,0}\), and \(\vec{k}_{trans,+1}\), respectively, with the starting point at \(\vec{k}_{ref,0}\). However, the level at which the intersection point with the dotted line on the semicircle is located cannot be identified, which corresponds to the evanescent wave vector \(\vec{k}_{Enumecent}\) in Figure 1. The dotted line and semicircle on the reflection side and transmission side are diffractive wavevectors \(\vec{k}_{ref,-2}\), \(\vec{k}_{ref,-1}\), \(\vec{k}_{ref,+1}\), \(\vec{k}_{trans,-3}\), \(\vec{k}_{trans,-2}\), \(\vec{k}_{trans,-1}\), \(\vec{k}_{trans,0}\), and \(\vec{k}_{trans,+1}\), whose starting point is the starting point of \(\vec{k}_{ref,0}\).