Three-dimensional analysis of structural coloration by a slanted dielectric grating