Triangular patterns phase shifting profilometry is a method of structured light whose three-dimensional reconstructions are susceptible to error from gamma distortion. In practice, the luminance nonlinearity caused by the gamma distortion effect of a digital projector and a digital camera yields undesired fringe intensity changes, which substantially reduce the measurement accuracy, and while the effects of the gamma distortion diminish with an increasing number of employed phase-shifted patterns. A gamma correction method based on the pre-coding of projected grating is proposed to reduce the measurement error caused by the gamma distortion. By applying an appropriate pre-coding value to the projected patterns, the gamma distortion effect is attenuated and the accuracy is enhanced. The linear least square is compensated the absolute coordinate residuals still existing after gamma correction. To verify the presented method in this paper, a 3D shape measurement experimental system is constructed using digital video projector and CCD camera. The experiment results shown that, the gamma pre-coding correction reduce the maximum residuals error of absolute coordinate by 72.2%. After the linear least square compensation, the maximum absolute coordinate residual is only 6.1% of without any correction or compensation. The reconstruction surface of a complex curve surface is hardly any waviness, which is clearly noted in the reconstruction of the same tested object without any correction or compensation.