teximport VEX function

Imports attributes from texture files.

Contexts: displace, fog, light, photon, shadow, surface

  1. int teximport(string map, attribute; int &value)

  2. int teximport(string map, attribute; float &value)

  3. int teximport(string map, attribute; vector &value)

  4. int teximport(string map, attribute; vector4 &value)

  5. int teximport(string map, attribute; matrix3 &value)

  6. int teximport(string map, attribute; matrix4 &value)

  7. int teximport(string map, attribute; string &value)

Overview

This function queries metadata stored in an image file (.rat or .tbf files, such as material textures and deep shadow maps). It returns 1 on success and 0 on failure. If the function fails, the value variable will not be modified, and so may be left uninitialized.

You can choose what properties are stored using the vm_saveoptions Houdini property on a camera or light (image:saveoptions in IFD). However, the defaults probably contain all the information you'd want. See rendering properties.

Queryable attributes

There are several generic attributes you can always query:

int texture:xres

X resolution of the texture map.

int texture:yres

Y resolution of the texture map.

int texture:channels

Number of channels in the texture map.

vector texture:resolution

Resolution of the texture as the vector (xres, yres, channels).

string texture:tokens

A space separated list of all attribute names you can query.

Example

cvex test(string map="Mandril.rat")
{
    string token;
    float fval;
    vector val;
    matrix mval;

    foreach(token; { "texture:xres",
                     "texture:yres",
                     "texture:channels",
                     "texture:resolution",
                     "texture:tokens",
                     "image:pixelaspect",    // user defined
                     "space:world" } )       // user defined
    {
        printf("----------------- %s ---------------------\n", token);
        if (teximport(map, token, fval))
            fprintf(stderr, "'%s' = %g\n", token, fval);
        else if (teximport(map, token, vval))
            fprintf(stderr, "'%s' = %g\n", token, vval);
        else if (teximport(map, token, mval))
            fprintf(stderr, "'%s' = %g\n", token, mval);
    }
}