shadowmap VEX function

The shadowmap function will treat the shadow map as if the image were rendered from a light source.

Contexts: image3d, chop, cop, pop, sop, surface, displace, fog, light, shadow, photon, cvex

See also: depthmap

  1. float shadowmap(string filename, vector Pndc, float spread, float bias, float quality)

  2. vector shadowmap(string , vector , float , float , float )

  3. float shadowmap(string , vector , float , float , float )

  4. vector shadowmap(string , vector , float , float , float )

  5. vector shadowmap(string , vector , vector , vector , vector , float , float , float )

Overview

The shadowmap function will treat the shadow map as if the image were rendered from a light source. You use this to access both depth maps and deep shadow maps. In both cases it returns a vector where each color component has the visibility of the light source to the point for that color.

Pndc is the position of the point being shaded in the NDC space of the light’s projection. spread is a softness control on the shadow. bias controls how accurate the depth samples need to be. quality is a general control to increase/decrease sampling, where 1 is default quality.

Note

This function returns the fractional amount of illumination which reaches the sample point. For example, if the point is fully in shadow, the return value will be 0, if it is fully illuminated, the return value will be 1.

Deep camera map channels

If the shadow map is an Deep camera map, shadowmap takes an optinal extra argument "channel", followed by the string name of the channel in the map evaluate.

shadowmap(mapname, pz, spread, bias, quality, "channel", channel);

This uses the same opacity semantics, so the function will return the complement of the actual color. So, to get accurate results, you will usually want to evaluate:

{1,1,1} - shadowmap(...);