occlusion VEX function

Computes ambient occlusion.

Contexts: fog, light, surface

See also: irradiance, pathtrace


  1. vector occlusion(vector P, vector N)

    Computes ambient occlusion at the point P with the normal N. Just as in the irradiance function, the hemisphere is sampled. However, unlike irradiance, surfaces intersected during the hemisphere sampling are not shaded. For this function to work properly, either a constant background color or an environment map must be specified in the optional scope parameters.

  2. void occlusion(float coverage&, vector missed_direction&, vector P, vector N)

    Instead of computing color information from ambient occlusion, this form computes the coverage (the percentage of occlusion) and the average direction of empty space. The average direction can be used to look up the color in a pre-blurred environment map.

Keyword arguments

See optional parameters .


The name of a VEX variable to use for variance anti-aliasing.

This variable must be imported from the hit surface, so it must be in the list of imported names (see “importing information back from the ray” below). If the named variable is not imported, this option will be ignored.

adaptive1 or 0

Turns on an automatic optimization that will reduce the number of samples when there is little variation in occlusion above the sample point. This can improve performance at the expense of some possible flickering or additional noise.