Home Reference VEX VEX functions 

diffuse vex function

Context: surface

Tags: pbr, shading

Returns the diffuse (Lambertian) illumination given the normalized surface normal.

  1. vector diffuse(vector nml)

  2. vector diffuse(vector nml, vector V, float roughness)

  3. bsdf diffuse()

  4. bsdf diffuse(vector nml)

See writing a PBR shader for information on BSDFs.

Returns the diffuse (Lambertian) illumination given the normalized surface normal.

The diffuse(vector nml, V; float roughness, ...) form uses the Oren-Nayar lighting model to compute the diffuse illumination for the surface. The Oren-Nayar lighting model is a more sophisticated lighting model than Lambertian lighting. The V vector represents a vector from the surface to the eye (i.e. -normalize(I)). With a roughness of 0, the Oren-Nayar lighting model is equivalent to the Lambertian model. As roughness increases toward 1, the illumination changes to mimic rougher materials (like clay). The Oren-Nayar form of diffuse() is more expensive than Lambertian diffuse lighting.

You can optionally specify a light mask.

BSDF version

  1. bsdf diffuse()

  2. bsdf diffuse(vector nml)

Diffuse reflections. This BSDF has an albedo of 0.5.