intersect_lights VEX function

Finds the nearest intersection of a ray with any of a list of (area) lights.

Contexts: displace, fog, light, shadow, surface

See also: getlights, getlightname

  1. intersect_lights(int lightids[], vector pos, vector dir, float time, int &lightid, float &dist)

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 P).

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:

lightid

The integer ID of the nearest intersected light. You can convert this ID into a light name using getlightname.

dist

The distance to the nearest intersected light.