The fringe projection 3D measurement method is a widely used 3D measurement technology, which utilizes a digital projector as the structural light source. However, the nonlinear intensity response of projectors results in non-sinusoidal fringe images captured by cameras, introducing phase errors that undermine measurement accuracy. We propose a nonlinear correction method based on precise pre-coding for digital fringe projection 3D measurement systems. By encoding only two sets of four-step phase-shifting fringe images into the projector and modeling the relationship among gamma value, pre-coding value, and ideal phase, the algorithm estimates accurate pre-coding values. Experimental validation demonstrates significant reductions in phase error standard deviation post-gamma correction on standard whiteboards, leading to an ∼84% increase in 3D point cloud height accuracy. In addition, the proposed method effectively mitigates the periodic water ripple phenomenon induced by nonlinear gamma effects. Experimental investigations on plaster sculpture and printed circuit board further validate the method's superiority, achieving higher phase accuracy and point cloud precision, with a measurement accuracy of 0.1 mm.