A waveguide, comprising: a first surface and a second surface, wherein: the first surface comprises a first plurality of grating structures; the waveguide is configured to guide an in-coupled light beam to undergo total internal reflection between the first surface and the second surface; the first plurality of grating structures is configured to disrupt the total internal reflection to cause at least a portion of the in-coupled light beam to couple out of the waveguide and project from the first surface, the portion of the in-coupled light beam coupled out of the waveguide forming out-coupled light beams such that the out-coupled light beams are configured to form an array of dots on a surface where the out-coupled light beams are projected on; the first surface is in an x-y plane; the in-coupled light beam propagates inside the waveguide substantially along the x-direction of the x-y plane; and the out-coupled light beams propagate substantially along a z-direction normal to the x-y plane; each grating structure of said first plurality of grating structures has a respective grating depth and a respective duty cycle; and characterized in that each grating structure of the first plurality of grating structures at respective x-direction positions along said first surface of said waveguide has at least one of a different grating depth or a different grating duty cycle, wherein at least one of the grating depth or grating duty cycle is set such that out-coupling efficiency is monotonically increased along a propagation direction of the in-coupled light beam to compensate loss of light power along the propagation direction in order to obtain a uniform output power for the out-coupled light beams, wherein the out-coupling efficiency is the percentage of the light undergoing total internal reflection that couples out of the waveguide at each grating. the first surface comprises a first plurality of grating structures; the waveguide is configured to guide an in-coupled light beam to undergo total internal reflection between the first surface and the second surface; the first plurality of grating structures is configured to disrupt the total internal reflection to cause at least a portion of the in-coupled light beam to couple out of the waveguide and project from the first surface, the portion of the in-coupled light beam coupled out of the waveguide forming out-coupled light beams such that the out-coupled light beams are configured to form an array of dots on a surface where the out-coupled light beams are projected on; the first surface is in an x-y plane; the in-coupled light beam propagates inside the waveguide substantially along the x-direction of the x-y plane; and the out-coupled light beams propagate substantially along a z-direction normal to the x-y plane; each grating structure of said first plurality of grating structures has a respective grating depth and a respective duty cycle; and characterized in that each grating structure of the first plurality of grating structures at respective x-direction positions along said first surface of said waveguide has at least one of a different grating depth or a different grating duty cycle, wherein at least one of the grating depth or grating duty cycle is set such that out-coupling efficiency is monotonically increased along a propagation direction of the in-coupled light beam to compensate loss of light power along the propagation direction in order to obtain a uniform output power for the out-coupled light beams, wherein the out-coupling efficiency is the percentage of the light undergoing total internal reflection that couples out of the waveguide at each grating. <EOS>