teximport VEX function
Imports attributes from texture files.
Contexts: displace, fog, light, photon, shadow, surface
-
int teximport(string map, attribute; int &value) -
int teximport(string map, attribute; float &value) -
int teximport(string map, attribute; vector &value) -
int teximport(string map, attribute; vector4 &value) -
int teximport(string map, attribute; matrix3 &value) -
int teximport(string map, attribute; matrix4 &value) -
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:
|
|
X resolution of the texture map. |
|
|
Y resolution of the texture map. |
|
|
Number of channels in the texture map. |
|
|
Resolution of the texture as the vector |
|
|
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); } }