This is what I've been told for PAPI's:
Each light box projects through a lens. The lens is designed so light passing through the lower half of the lens is red, and the upper half, white. There is a sharp dividing line between the two - no blurring!
The four lights in an array are all calibrated to point up at different angles. For example, (in degrees above horizontal) the four lights might be set for 2°, 2.5°, 3.5° & 4° respectively. Anyone on a glideslope of 2.5° to 3.5° sees two red, two white. A pilot descending lower will see three reds, or four reds if below 2° glideslope.
Similarly, a high glideslope will give three or four white lights, with one or nil red lights.
Note that my calibration numbers are fictitious - perhaps someone else can provide "real" angles?
cheers, O8