I’m looking to implement udim textures.
I see a couple mentions to layered textures in the docs, but no examples, however it seems this might not be exactly the direction to go? I’m not sure how I would be able to get the proper layer for the needed UV value, as there could be more or less UDIM textures then expected UDIM uv values.
I was thinking to create a texture sampler per udim, and store their IDs in a 1D buffer. Index 0 would be the texture ID for udim 1001, missing udim would have some known value like -1, and the Index N would be the last index.
Then take the uv values, and based on those get the int ID, if it’s valid then sample that texture for the UV value.
Does that sound like a reasonable plan?
Look at this thread: https://devtalk.nvidia.com/default/topic/1038035/texture-fetch-for-layered-texture/
You can build an array of textures (which are layered textures then). Using rtTex2DLayered(…) accesses these bindless textures.
Or you can do it as you already suggested. The main difference is that in the array ALL textures are allocated. Also the missing ones, where you would set a known value of -1. So storing the ids of bindless textures within a 1D buffer would save memory for all the missing ones.
How you can access these texture ids you can see here:
There “parameters.albedoID” is such an ID, that is stored in a 1D buffer: rtBuffer sysMaterialParameters;
Then "rtTex2D" with parameters “parameters.albedoID, u,v” accesses one texture over such an ID.
As you can see there’s a checking “if (parameters.albedoID != RT_TEXTURE_ID_NULL)” which allows you the case for missing ones. So you should use RT_TEXTURE_ID_NULL instead of a known value of -1 for them