GLSL Accessing instance data TOP texture coordinate?

With all the new features allowing direct instancing via TOPs to Geo COMPs I’m wondering if it’s possible to now access the UV coordinate of the default instancing OP if it is a TOP by way of the instance ID in shader. In the past we’ve had to so some modulo and division on the instanceID based on the width/height of a texture when doing it the old school way before the TOP instance feature. It may already be available, but I’m confused a bit in the documentation when things are referring to Instance Textures ( as in a texture per instance) versus textures used as instance attribute data.

The use case I have is using a cache of position data to draw a trail, so ideally i would use the current position TOP data as the instancing OP and then in the shader access a 3D texture that has some steps back in time to inform the Geometry shader emitting points. I’m fine doing it the “old school” way, just wondering if there are some new GLSL functions that could give access to the source data’s UV.

Thanks!
-p

The source datas UV is calculated the same way as you did before. I use texelFetch get the sample, so these generate non-normalized coordinates for the texture.

ivec2 size = textureSize(samplerName, 0);
ivec2 coord;
coord.x = index % size.x;
coord.y = index / size.x;

Thanks Malcolm for the best practice code. Another question, for each instance op ( transform, rotate, color, etc) if it were set as TOP do they have specifically declared sampler names in the shader automatically or is it all happening somehow prior to being available in the shader?

I suppose in the case of finding the UV it can be any of the textures coming in if they are the same width/height, but still seems like it might be useful to access the instance data TOP by name in the shader maybe? I could see somehow maybe wanting to further manipulate something like scale or rotate which doesn’t seem immediately accessible in contrast to P or color if that makes sense.

Thanks
Peter

Hmm, might have answered my own question sorry, i guess that’s what this function is for yeah?

mat4 TDInstanceMat();