#pragma annotation gain "gadgettype=floatfield;label=Gain;hint=Overall gain value for textures." #pragma annotation texname "gadgettype=inputfile;label=Input Textures;hint=Path and first part of filename. ie... /pathto/mytexture.[udim].tdl should be entered as '/pathto/mytexture'" #pragma annotation fileext "gadgettype=optionmenu:tdl:tex:tx:tif:exr;label=File Extension;hint=File extension used by textures. tdl is used by 3Delight, tex/tx is used by Renderman. There is the option for using tif and exr, but it's recommended you use tdl or tex." #pragma annotation maxU "gadgettype=floatfield;label=Max UDimension;hint=The maximum dimension along U. Mari uses 10, Zbrush allows you to set the value." #pragma annotation reverset "gadgettype=checkbox;label=Reverse T;hint=Use this if your textures come out upside down." #pragma annotation usevariant "gadgettype=checkbox;label=Use Variant;hint=Use texture variant. " #pragma annotation varname "gadgettype=inputfile;label=Variant Name;hint=Name of texture variant. ie... /pathto/mytexture_variant.[udim].tdl should be entered as 'variant']" #pragma annotation useanimmap "gadgettype=checkbox;label=Use Animated Maps;hint=Use animated texture maps." #pragma annotation framenumber "gadgettype=floatfield;label=Frame;hint=Frame number to use from animated maps. Maps should be named like so '/pathto/mytexture.0001.[udim].tdl'" surface udim_texture( float gain = 1; string texname = ""; string fileext = "tdl"; float maxU = 10; float reverset = 0; float useanimmap = 0; float framenumber = 0; float usevariant = 0; string varname = ""; output varying color _ud = 0; ) { color surfcolor = 1; float ss = floor (s); float tt = floor (t); float abstt = abs (tt); uniform string texn; uniform string uDim = "1001"; uniform string frame = ""; varying float udim = (abstt * maxU + ss + 1001); uniform float mapnumber = 1000; while( mapnumber < udim ){ mapnumber += 1; } uDim = format( "%04d" , mapnumber); frame = format ( "%04d", framenumber); if(texname != "") { texn = texname; if (usevariant > 0) texn = concat ("_", texn, varname); if (useanimmap > 0) texn = concat (".", texn, frame); texn = concat (texn, ".", uDim, ".", fileext); if (reverset > 0) { surfcolor = texture(texn, s - ss, abs((t - tt) - 1)); } else { surfcolor = texture(texn, s - ss, t - tt); } } Oi = Os; setcomp(_ud, 0, ss); setcomp(_ud, 1, tt); setcomp (_ud, 2, udim); Ci = Oi * gain * surfcolor; }