Houdini 12 VEX VEX functions

Finds the nearest intersection of a ray with any of a list of (area) lights and runs the light shader at the intersection point.

  1. 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 component

  • PBR_GLOSSY_MASK - glossy component

  • PBR_SPECULAR_MASK - mirror specular component

  • PBR_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 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:

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

Contexts: displace, fog, light, shadow, surface

Related topics