sample_bsdf VEX function

Samples a bsdf.

Contexts: displace, fog, light, shadow, surface

See also: eval_bsdf, emission_bsdf

  1. sample_bsdf(bsdf b, vector viewer, vector geo_normal, vector &out_vector, vector &eval, int &type, float sx, float sy, int mask)

viewer

Vector toward viewer.

geo_normal

Geometric normal.

sx and sy

Random values, such as generated by nextsample. Different values of sx and sy translate into different random directions to sample.

mask

A bitmask indicating which types of bounces to evaluate.

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_EMISSION_MASK - emission component

The function modifies the values of the following arguments:

out_vector

The sampled outgoing vector.

eval

The color of the evaluated component.

type

The type of component sampled. This uses the same constants as in the mask argument.