string expand_udim(float u, float v, string path, ...)
Scans the input path for special conversion characters to perform either UDIM or UVTILE style filename expansion.
This is similar to texprintf, with two significant differences:
There are no variadic print arguments. Only UDIM/UVTILE expansion is performed.
If UDIM/UVTILE expansion was performed, the function checks to see if the texture exists and is accessible.
The texture coordinates to translate into a UDIM tile specification.
A file path. Special character sequences in the path will be expanded into UDIM specifiers based on the given UV coordinates. The special conversion sequences are:
The UDIM coordinate, as computed by
The UVTILE style u-coordinate (
The UVTILE style v-coordinate (
Expands both u and v coordinates in the form
d conversion specifier for texture identification can be modified with
field modifiers. For example
Normally, the function checks whether the expanded path exists and is readable. If you pass the
"checkfile", 0 pair, the function will not perform this check.
The path with any UDIM control sequences replaced.
If the expanded file path does not exist or is not readable, the function will return an empty string, unless you turn off the
checkfile variadic argument.
expand_udim(3.1, 4.15, "map_%(UDIM)d.rat")- Returns “map_1044.rat”
expand_udim(3.1, 4.15, "map_%(U)02d_%(V)02d.rat")- Returns “map_04_05.rat”
expand_udim(3.14, 11.5, "map_u%(U)d_v%(V)d.rat")- Returns “map_u4_v12.rat”
expand_udim(3.14, 11.5, "missing_file%(UDIM)d.rat")- Returns “” for missing files.
expand_udim(3.14, 11.5, "missing_file%(UDIM)d.rat", "checkfile", 0)- Returns “missing_file1044.rat” since “checkfile” is disabled.
expand_udim(3.14, 11.5, "/path/file.rat")- Returns “/path/file.rat” whether the file exists or not since there are no UDIM/UVTILE expansions.
// sprintf() will leave the %(UDIM)d format sequence unmodified. string map = sprintf("%s/%s_%(UDIM)d.rat", texture_path, texture_base); // Expand the %(UDIM)d, returning an empty string if the map doesn't exist. map = expand_udim(u, v, map); if (map != "") Cf = texture(map, u, v);