trace VEX function

Sends a ray from P along the normalized vector D.

Contexts: displace, fog, light, shadow, surface

See also: rayhittest, Raytrace VOP

  1. void trace(vector cv&, vector of&, float af&, vector P, vector D, float shadow_bias, float max_contrib, ...)

    Sends a ray from P along the normalized vector D. The resulting color, opacity and alpha will be put in the export variables.

    shadow_bias is typically a small number which is used to prevent self-shading.

    max_contrib controls how much the result of the trace() call will contribute to the resulting pixel color. max_contrib has no effect on the results of the trace() call.

  2. int trace(vector pos, vector dir, float time, ...)

    Sends a single ray into the scene at time and retrieves information from the hit surface. A return value of 1 means the ray hit a surface.

    This function behaves the same way as a gather loop without any looping. The samples, angle, distribution, samplebase, and variancevar arguments to gather are not supported for this function. See gather for more information.

See optional parameters .

Tip

When hit testing polygons you can get lots of rays missing. In these cases triangulating the geometry can improves hits.