The Apollo LM had a radar altimeter which was particularly critical in the final stages of landing. It could be set to two different pitch angles, either aimed backwards by 24º to be used during the earlier part of descent when the LM was pitched far back, or aimed directly downwards for the final approach.
As the LM pitched and rolled during its final descent maneuvers, the radar beam would unavoidably be swept around the lunar terrain. This would yield two sources of error: the height difference between the beam contact point and the terrain directly under the LM, and the off-angle "cosine factor" (the radar beam would be the hypotenuse of a right triangle with the altitude as the adjacent side, getting longer as the spacecraft attitude departed further from the vertical).
Obviously the varying terrain couldn't really be accounted for (or could it?†) but the LM guidance system would be aware of its pitch and roll attitude relative to the local vertical, so it could factor out the cosine for a better estimate of the correct altitude.
The LM generally wouldn't pitch or roll beyond 20º in the terminal phase of flight, so the cosine error would be no more than 13% (at 20º pitch and 20º roll) and usually much less, probably around 3.5% when the commander took manual control.
Were the altitude figures presented to the crew by the instruments in the LM corrected for the LM's attitude?
† The guidance computer did include a very crude, low resolution 2-D representation of a cross section of terrain at the expected landing site, which could conceivably be used for correcting altitude for terrain in the downrange direction, but would be useless at best in the crossrange direction.