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.h:
PBR_DIFFUSE_MASK- diffuse componentPBR_GLOSSY_MASK- glossy componentPBR_SPECULAR_MASK- mirror specular componentPBR_VOLUME_MASK- volume component
Only area lights will produce intersections.
lightids
| An array of light IDs, as returned by getlights. |
pos
| The origin of the ray (such as the global variable |
dir
| Direction vector from the origin. The length of this vector does not affect the distance the ray will travel. |
time
| Time to send the ray at. |
The function modifies the values of the following arguments:
idx
| The light index for the light that was hit by the ray, or -1 if no intersection was found. |
dist
| The distance to the nearest intersected light. |
clr
| The light color set by the light shader. |
scale
| The light average hemispherical intensity (for area lights). |