Small shader to show the current UDIM tile in the render. Useful if you need to know which UDIM tile to look up!
Download links
http://www.rensheeren.com/osl/showUDIM_tex_v001.osl
http://www.rensheeren.com/osl/rhfunctions.h
Save both in the same folder, both are needed for the shader to work.
Features
– It displays the current UDIM tile number.
How to use
Vray:
– Create a VRay OSL Texture map.
– Load in the downloaded OSL shader.
– Works best with a VrayLightMtl (no clamping).
– Make sure ‘wrap texture coordinates’ is disabled!
Properties
– display mode
Different options to display the UDIM tile number. Either as text or as colour information.
– color_bg
Background colour.
– color_text
Text colour.
– random_bg_col
Creates a random background colour for each UDIM tile.
– mode_1_spacing
How many text repeats you get for display mode 1.
Code
#include "rhfunctions.h" /* showUDIM_tex_v001 By Rens Heeren (mail [at] rensheeren [dot] com) Use as an OSL texture, not as an OSL material. Simple shader to show the UDIM tile number in the render. For example you have a part of the model where the map isn't working. Which UDIM is that? You use this shader. Usage: - For best result don't clamp the output. - For VRay specifically this means using it with a VRayLightMtl. - Make sure wrap texture coords is off in the OSL shader! Oterwise it will display only UDIM 1001. Use at your own risk. 2016/04/02 - Created (rh) */ shader showUDIM_tex_v001 ( int display_mode = 1 [[ string widget = "mapper", string description = "1 UDIM text, 2 UV info, 3 UDIM as BG, 4 UV as BG", string options = "1 UDIM text:1|2 UV info:2|3 UDIM as BG:3|4 UV as BG:4" ]], color color_bg = color(0.5) [[ string description = "Background colour" ]], color color_text = color(1, 0, 0) [[ string description = "Text colour" ]], int random_bg_col = 0 [[ string widget = "checkBox", string description = "Random colour per UDIM tile" ]], float mode_1_spacing = 10.0 [[ string description = "Number of text repeats for display mode 1" ]], output color col_out = color(0), output float alpha_out = 1.0 ) { color c_bg = color_bg; color c_txt = color_text; int i_rndBG = random_bg_col; int i_mode = display_mode; float f_spacing = mode_1_spacing; color c_main = color(0); int i_output = 0; float f_uclamp = clamp(u, -9999.0, 9999.0); float f_vclamp = clamp(v, -9999.0, 9999.0); float f_uspace = ceil(f_uclamp); float f_vspace = ceil(f_vclamp); int i_uspace = int(f_uspace); int i_vspace = int(f_vspace); int i_ufloor = int(floor(f_uclamp)); int i_vfloor = int(floor(f_vclamp)); int i_udimErr = 0; if (i_uspace > 9 || i_vspace > 899 || i_uspace < 1 || i_vspace < 1) { i_udimErr = 1; } int i_udim = 1000; if (i_udimErr == 0) { i_udim = 1000 + i_ufloor + 1 + i_vfloor * 10; } int i_udim1, i_udim2, i_udim3, i_udim4; fn_format04d(i_udim, i_udim1, i_udim2, i_udim3, i_udim4); int i_uspace1, i_uspace2, i_uspace3, i_uspace4; fn_format04d(i_uspace, i_uspace1, i_uspace2, i_uspace3, i_uspace4); int i_vspace1, i_vspace2, i_vspace3, i_vspace4; fn_format04d(i_vspace, i_vspace1, i_vspace2, i_vspace3, i_vspace4); if (i_rndBG) { c_bg[0] = cellnoise((f_uspace / 3) * 123, f_vspace * 456); c_bg[1] = cellnoise((f_uspace * 3) * 689, f_vspace * 123); c_bg[2] = cellnoise((f_uspace * 2) * 456, f_vspace * 789); c_bg /= 2; } float f_unit = 1.0 / 11.0; float f_pad = f_unit / 10.0; if (i_mode == 1) { //UDIM number f_unit = 1.0 / f_spacing; f_pad = f_unit / 10.0; float f_unit1 = (floor((u - i_ufloor)/(5 * f_unit)))*5*f_unit; float f_rptu = floor(((u - i_ufloor) / (f_unit1))) * (f_unit1); float f_rptv = floor(((v - i_vfloor) / f_unit)) * f_unit; if (i_udimErr == 0) { i_output += fn_charprint( (i_ufloor + f_rptu + f_unit * 0 + f_pad), (i_ufloor + f_rptu + f_unit * 1 - f_pad), (i_vfloor + f_rptv + f_pad), (i_vfloor + f_rptv + f_unit - f_pad), u, v, (i_udim1 + 28)); i_output += fn_charprint( (i_ufloor + f_rptu + f_unit * 1 + f_pad), (i_ufloor + f_rptu + f_unit * 2 - f_pad), (i_vfloor + f_rptv + f_pad), (i_vfloor + f_rptv + f_unit - f_pad), u, v, (i_udim2 + 28)); i_output += fn_charprint( (i_ufloor + f_rptu + f_unit * 2 + f_pad), (i_ufloor + f_rptu + f_unit * 3 - f_pad), (i_vfloor + f_rptv + f_pad), (i_vfloor + f_rptv + f_unit - f_pad), u, v, (i_udim3 + 28)); i_output += fn_charprint( (i_ufloor + f_rptu + f_unit * 3 + f_pad), (i_ufloor + f_rptu + f_unit * 4 - f_pad), (i_vfloor + f_rptv + f_pad), (i_vfloor + f_rptv + f_unit - f_pad), u, v, (i_udim4 + 28)); } else { i_output += fn_charprint( (i_ufloor + f_rptu + f_unit * 0 + f_pad), (i_ufloor + f_rptu + f_unit * 1 - f_pad), (i_vfloor + f_rptv + f_pad), (i_vfloor + f_rptv + f_unit - f_pad), u, v, 5); i_output += fn_charprint( (i_ufloor + f_rptu + f_unit * 1 + f_pad), (i_ufloor + f_rptu + f_unit * 2 - f_pad), (i_vfloor + f_rptv + f_pad), (i_vfloor + f_rptv + f_unit - f_pad), u, v, 18); i_output += fn_charprint( (i_ufloor + f_rptu + f_unit * 2 + f_pad), (i_ufloor + f_rptu + f_unit * 3 - f_pad), (i_vfloor + f_rptv + f_pad), (i_vfloor + f_rptv + f_unit - f_pad), u, v, 18); } clamp(i_output, 0, 1); c_main = mix(c_bg, c_txt, i_output); } if (i_mode == 2) { float f_t2v1 = i_vfloor + 9 * f_unit + f_pad; float f_t2v2 = i_vfloor + 10 * f_unit - f_pad; float f_t4v1 = i_vfloor + 8 * f_unit + f_pad; float f_t4v2 = i_vfloor + 9 * f_unit - f_pad; float f_t5v1 = i_vfloor + 7 * f_unit + f_pad; float f_t5v2 = i_vfloor + 8 * f_unit - f_pad; // U txt i_output += fn_charprint((i_ufloor + 1 * f_unit + f_pad), (i_ufloor + 2 * f_unit - f_pad), f_t2v1, f_t2v2, u, v, 21); // V txt i_output += fn_charprint((i_ufloor + 1 * f_unit + f_pad), (i_ufloor + 2 * f_unit - f_pad), f_t4v1, f_t4v2, u, v, 22); // UDIM txt i_output += fn_charprint((i_ufloor + 1 * f_unit + f_pad), (i_ufloor + 2 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, 21); i_output += fn_charprint((i_ufloor + 2 * f_unit + f_pad), (i_ufloor + 3 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, 4); i_output += fn_charprint((i_ufloor + 3 * f_unit + f_pad), (i_ufloor + 4 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, 9); i_output += fn_charprint((i_ufloor + 4 * f_unit + f_pad), (i_ufloor + 5 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, 13); if (i_udimErr == 0) { // U number i_output += fn_charprint((i_ufloor + 6 * f_unit + f_pad), (i_ufloor + 7 * f_unit - f_pad), f_t2v1, f_t2v2, u, v, (i_uspace1 + 28)); i_output += fn_charprint((i_ufloor + 7 * f_unit + f_pad), (i_ufloor + 8 * f_unit - f_pad), f_t2v1, f_t2v2, u, v, (i_uspace2 + 28)); i_output += fn_charprint((i_ufloor + 8 * f_unit + f_pad), (i_ufloor + 9 * f_unit - f_pad), f_t2v1, f_t2v2, u, v, (i_uspace3 + 28)); i_output += fn_charprint((i_ufloor + 9 * f_unit + f_pad), (i_ufloor + 10 * f_unit - f_pad), f_t2v1, f_t2v2, u, v, (i_uspace4 + 28)); // V number i_output += fn_charprint((i_ufloor + 6 * f_unit + f_pad), (i_ufloor + 7 * f_unit - f_pad), f_t4v1, f_t4v2, u, v, (i_vspace1 + 28)); i_output += fn_charprint((i_ufloor + 7 * f_unit + f_pad), (i_ufloor + 8 * f_unit - f_pad), f_t4v1, f_t4v2, u, v, (i_vspace2 + 28)); i_output += fn_charprint((i_ufloor + 8 * f_unit + f_pad), (i_ufloor + 9 * f_unit - f_pad), f_t4v1, f_t4v2, u, v, (i_vspace3 + 28)); i_output += fn_charprint((i_ufloor + 9 * f_unit + f_pad), (i_ufloor + 10 * f_unit - f_pad), f_t4v1, f_t4v2, u, v, (i_vspace4 + 28)); //UDIM number i_output += fn_charprint((i_ufloor + 6 * f_unit + f_pad), (i_ufloor + 7 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, (i_udim1 + 28)); i_output += fn_charprint((i_ufloor + 7 * f_unit + f_pad), (i_ufloor + 8 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, (i_udim2 + 28)); i_output += fn_charprint((i_ufloor + 8 * f_unit + f_pad), (i_ufloor + 9 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, (i_udim3 + 28)); i_output += fn_charprint((i_ufloor + 9 * f_unit + f_pad), (i_ufloor + 10 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, (i_udim4 + 28)); } else { i_output += fn_charprint((i_ufloor + 6 * f_unit + f_pad), (i_ufloor + 7 * f_unit - f_pad), f_t2v1, f_t2v2, u, v, 5); i_output += fn_charprint((i_ufloor + 7 * f_unit + f_pad), (i_ufloor + 8 * f_unit - f_pad), f_t2v1, f_t2v2, u, v, 18); i_output += fn_charprint((i_ufloor + 8 * f_unit + f_pad), (i_ufloor + 9 * f_unit - f_pad), f_t2v1, f_t2v2, u, v, 18); i_output += fn_charprint((i_ufloor + 6 * f_unit + f_pad), (i_ufloor + 7 * f_unit - f_pad), f_t4v1, f_t4v2, u, v, 5); i_output += fn_charprint((i_ufloor + 7 * f_unit + f_pad), (i_ufloor + 8 * f_unit - f_pad), f_t4v1, f_t4v2, u, v, 18); i_output += fn_charprint((i_ufloor + 8 * f_unit + f_pad), (i_ufloor + 9 * f_unit - f_pad), f_t4v1, f_t4v2, u, v, 18); i_output += fn_charprint((i_ufloor + 6 * f_unit + f_pad), (i_ufloor + 7 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, 5); i_output += fn_charprint((i_ufloor + 7 * f_unit + f_pad), (i_ufloor + 8 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, 18); i_output += fn_charprint((i_ufloor + 8 * f_unit + f_pad), (i_ufloor + 9 * f_unit - f_pad), f_t5v1, f_t5v2, u, v, 18); } clamp(i_output, 0, 1); c_main = mix(c_bg, c_txt, i_output); int i_box1 = fn_charprint((i_ufloor + 1 * f_unit + f_pad), (i_ufloor + 2 * f_unit - f_pad), (i_vfloor + 6 * f_unit + f_pad), (i_vfloor + 7 * f_unit - f_pad), u, v, 27); int i_box2 = fn_charprint((i_ufloor + 2 * f_unit + f_pad), (i_ufloor + 3 * f_unit - f_pad), (i_vfloor + 6 * f_unit + f_pad), (i_vfloor + 7 * f_unit - f_pad), u, v, 27); color c_box1 = color(i_uspace, i_vspace, 0); color c_box2 = color(u, v, 0); c_box1 *= i_box1; c_box2 *= i_box2; c_main *= 1 - i_box1; c_main *= 1 - i_box2; c_main = c_main + c_box1 + c_box2; } if (i_mode == 3) { if (i_udimErr == 0) { c_main = color(float(i_udim)); } else { c_main = color(1000.0, 0, 0); } } if (i_mode == 4) { c_main = color(u, v, 0); } col_out = c_main; }