Yes, indeed I'm using osl.
Thanks a lot for the great help - as always, I'll try it.

haggi

Am 02.02.2015 um 21:11 schrieb Larry Gritz:
(CC'ing osl-dev because the fun part of this is on the OSL side.)


On Feb 2, 2015, at 11:52 AM, haggi krey <[email protected]> wrote:

I am reading image files with OIIO in my texure system.
Is it possible to use udim tiled textures from Mari, Mudbox or Zbrush with OIIO?
And if yes, how? Do I have to implement the reading of the correct file name by 
myself in my texture file osl shader or are there any helpful procedures in 
OIIO?

You need to generate the texture name based on the coordinates:

        umap = int(s);
        vmap = int(t);
        udim = 1001 + 10*vmap + umap;
        filename = format ("%s%04d.tx", basename, udim);

        look up texture (filename, s-umap, t-vmap, ...)

or, if your v's are all upside down, then 1.0 - (t-vmap).

BUT... if you are using this from OSL (I'm presuming, because I see you on the 
mail list there frequently), the repeated calls to create strings on every 
shade will be a bottleneck. But there's a special trick to make it super fast 
and fully constant folded!


shader
udimtexture (string basename = "",
           float s = 0 [[int lockgeom = 0]],
           float t = 0 [[int lockgeom = 0]],
           output color Cout = 0)
{
#define NAME(i) format("%s%d.tx",basename,i+1001)
#define TENNAMES(j)  
NAME(10*j+0),NAME(10*j+1),NAME(10*j+2),NAME(10*j+3),NAME(10*j+4), \
                     
NAME(10*j+5),NAME(10*j+6),NAME(10*j+7),NAME(10*j+8),NAME(10*j+9)
#define TENROWS     
TENNAMES(0),TENNAMES(1),TENNAMES(2),TENNAMES(3),TENNAMES(4), \
                     TENNAMES(5),TENNAMES(6),TENNAMES(7),TENNAMES(8),TENNAMES(9)

     string filenames[100] = { TENROWS };
     // The magic here is that the 'format' calls, since their parameters in 
this
     // macro expansion are all constant, will be constant-folded at runtime, 
and thus
     // the entire filenames[] array will become just constant memory that is 
initialized
     // just once, NOT every time the shader executes.
     // NOTE: if you expect more than 10 rows in v, adjust the above as needed.

#undef NAME
#undef TENNAME
#undef TENROW

     int umap = int(s);
     int vmap = int(t);
     int udim = 1001 + 10*vmap + umap;
     string filename = filenames[udim];   // MAGIC! just an array lookup, no 
format calls
     Cout = texture (filename, s-umap, 1.0 - (t-vmap));
}





--
Larry Gritz
[email protected]



_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org




_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to