Samples a 3D position on a light source and runs the light shader at that point.
int sample_light(int lightid, vector pos, vector sam, float time, vector &pos, vector &clr, float &scale)
The return value from
sample_light is a bitmask indicating which types of
bounces the light affects.
The following bitmask constants are defined in
PBR_DIFFUSE_MASK- diffuse component
PBR_GLOSSY_MASK- glossy component
PBR_SPECULAR_MASK- mirror specular component
PBR_VOLUME_MASK- volume component
The function takes the following arguments:
An integer identifying a light. You can get a list of light IDs for lights affecting the currently shaded surface with getlights.
The surface point from which lights should be sampled. Area light sources will attempt to distribute samples by solid angle from the position - that is, light geometry that is closer to the position will receive more samples.
A vector of random values, such as those generated by nextsample. Currently only the first 2 components of
Time to shade at.
The function modifies the values of the following arguments:
The sampled position on the light source.
The light color set by the light shader.
The light average hemispherical intensity (for area lights).
clr *= scale / luminance(clr);