Nocturnal bees, wasps and ants have considerably larger ocelli than their diurnal relatives, suggesting an active role in vision at night. In a first step to understanding what this role might be, the morphology and physiological optics of ocelli were investigated in three tropical rainforest species - the nocturnal sweat bee Megalopta genalis, the nocturnal paper wasp Apoica pallens and the diurnal paper wasp Polistes occidentalis - using hanging-drop techniques and standard histological methods. Ocellar image quality, in addition to lens focal length and back focal distance, was determined in all three species. During flight, the ocellar receptive fields of both nocturnal species are centred very dorsally, possibly in order to maximise sensitivity to the narrow dorsal field of light that enters through gaps in the rainforest canopy. Since all ocelli investigated had a slightly oval shape, images were found to be astigmatic: images formed by the major axis of the ocellus were located further from the proximal surface of the lens than images formed by the minor axis. Despite being astigmatic, images formed at either focal plane were reasonably sharp in all ocelli investigated. When compared to the position of the retina below the lens, measurements of back focal distance reveal that the ocelli of Megalopta are highly underfocused and unable to resolve spatial detail. This together with their very large and tightly packed rhabdoms suggests a role in making sensitive measurements of ambient light intensity. In contrast, the ocelli of the two wasps form images near the proximal boundary of the retina, suggesting the potential for modest resolving power. In light of these results, possible roles for ocelli in nocturnal bees and wasps are discussed, including the hypothesis that they might be involved in nocturnal homing and navigation, using two main cues: the spatial pattern of bright patches of daylight visible through the rainforest canopy, and compass information obtained from polarised skylight (from the setting sun or the moon) that penetrates these patches.