Finds the nearest intersection of a ray with any of a list of (area) lights and runs the light shader at the intersection point.
int intersect_lights(int lightids, vector pos, vector dir, float time, int &idx, float &dist, vector &clr, float &scale)
If no light was hit by the ray,
intersect_lights will return 0. If a light
was hit, the return value will be a bitmask indicating what 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
Only area lights will produce intersections.
An array of light IDs, as returned by getlights.
The origin of the ray (such as the global variable
Direction vector from the origin. The length of this vector does not affect the distance the ray will travel.
Time to send the ray at.
The function modifies the values of the following arguments:
The light index for the light that was hit by the ray, or -1 if no intersection was found.
The distance to the nearest intersected light.
The light color set by the light shader.
The light average hemispherical intensity (for area lights).