b_udimmask
It’s been a while… Busy days :)

Occasionally there might be the need for LookDev Artists to adjust areas of a shader based on different UDIMs. If an asset has a continuous mesh that is only separated by UDIMs (eg nails on a character or decorative parts of clothing) it can be useful to create masks for specific UDIMs in the shading network to isolate areas of interest.

It is relatively straight forward to get the integer values of each UDIM in a shader by just creating a Nodegraph that resembles the UDIM formula:
1000+(floor(u)+1)+(floor(v)*10)

You can output the result into a compare node in your renderer of choice and check whether it matches against a certain UDIM. While this is fine for 1 or 2 UDIMs it gets quite cumbersome with many UDIMs.

As I like playing with OSL I put together a version that allows you to create masks from a specified list of UDIMs. It expects a comma-separated list of UDIM tiles. You can also specify ranges. Eg 1001,1003-1006,1015,125 will select the following UDIMs: 1001,1003,1004,1005,1006,1015,1025.
You can also just output the raw UDIM tiles integers if you want to create more complex masks downstream.

There are just a few caveats:
1) The input is a string, so internally it’s checking against a regex to see if the passed input is a valid list of UDIMs. This can potentially be expensive in larger shading networks.
2) At the moment there’s a hard-coded maximum of 10 entries that are allowed for performance reasons (note that ranges such as 1001-1005 count as 1 entry). You can edit the #define MAX_TILES 10 in the supplied .osl file if you need more.
3) At the moment I could only test it with Arnold. Not sure if Blender supports UDIMs properly in this way. RenderMan should work as well.

You can download it HERE from github.

Here’s a quick demo:

OSL UDIM Mask from Julius Ihle on Vimeo.

_________________________________________________
If this post has helped you in any way you can express your gratefulness by using the Donate Button below to buy me a coffee! :)

3M5xNSV7g2NzVpHMqzYKhgoKJZ8CWa644m
bc_ldgr_qrcode