There is an ambient light sensor near the webcam (not part of the webcam) that is used for this. If you shine a flashlight on your camera, you'll see it about 75mm right of the camera.