colormap VEX function

There are various forms for looking up a color from a disk image.

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

  1. vector colormap(string filename, vector uvw)

    This function will lookup a single sample of from the filename given. The first two components of the vector are used to reference the image (in 0 to 1 space). No area sampling is done, but bilinear interpolation is done on raw pixel values.

  2. vector4 colormap(string filename, vector uvw)

  3. vector colormap(string filename, float u, float v)

    This function will lookup a single sample of from the filename given. The first two components of the vector are used to reference the image (in 0 to 1 space). No area sampling is done, but bilinear interpolation is done on raw pixel values.

  4. vector4 colormap(string filename, float u, float v)

  5. vector colormap(string filename, vector uv, vector du, vector dv, int samples)

    This function will filter the area of the image enclosed by the quadrilateral formed by (uv)-(uv+du)-(uv+du+dv)-(uv+dv). The quadrilateral will be sampled stochastically using the number of samples specified (unless the image is a .rat file). Each sample will use bilinear interpolation on raw pixel values.

  6. vector4 colormap(string filename, vector uv, vector du, vector dv, int samples)

  7. vector colormap(string filename, vector uv0, vector uv1, vector uv2, vector uv3)

    This function will filter the area of the image enclosed by the quadrilateral formed by (uv0)-(uv1)-(uv2)-(uv3). The quadrilateral will be sampled stochastically using the number of samples specified (unless the image is a .rat file). Each sample will use bilinear interpolation on raw pixel values.

  8. vector4 colormap(string filename, vector uv0, vector uv1, vector uv2, vector uv3)

  9. vector colormap(string filename, float u0, float v0, float u1, float v1, float u2, float v2, float u3, float v3, int samples)

    This function will sample the area enclosed by the quadrilateral (uv0),(uv1),(uv2),(uv3). The quadrilateral will be sampled stochastically using the number of samples passed in (unless the image is a .rat file). Each sample will use bilinear interpolation on raw pixel values.

  10. vector4 colormap(string filename, float u0, float v0, float u1, float v1, float u2, float v2, float u3, float v3, int samples)

There are various forms for looking up a color from a disk image. There are typically two forms of each function, one which returns a vector (RGB values only) and the other which returns a vector4 (RGB and Alpha).

There are corresponding versions of each of the above functions which return vector4 data types (which include alpha information in the fourth component of the vector4). If an image doesn’t have an alpha channel associated with it (e.g. a JPEG image), the alpha will be set to 1.

The rawcolormap function is the same as colormap but does not do bilinear interpolation of the raw pixel values.

You can specify additional keyword,value argument pairs to set filtering options for the texture. These arguments must be defined at load time (literals or parameters).

To specify one of the additional arguments, pass the keyword as a string, with the next argument being the value for the keyword. For example ..., "wrap", "clamp", "border", {.1,1,1}). See optional image filter arguments .

Examples of specifying filter parameters:

colormap(map, u, v, "smode", "decal", "tmode", "repeat", "border", {.1,1,1});
colormap(map, u, v, "mode", "clamp", "width", 1.3);
colormap(map, u, v, "filter", "gauss", "width", 1.3, "mode", "repeat");