How to create 2D texture array in glslTOP

Hi, I want to create 2D texture array with glslTOP, How to put each frame on a different slice?
Thank you!

I believe a GLSL TOP on it’s own can’t really accumulate frames like this from a single input since it operates all at once on every slice, every frame. Do you think you may be better off starting with a Texture3D or cache TOP which by default stores incoming frames as slices. Texture3D can then be used as an input to a GLSL TOP so you can manipulate the slices via the w coordinate. Does that help? Probably also depends what you’re trying to do down stream, as a Cache TOP is also quite useful if you are trying to get at single “past” frames… Also depends on whether you are trying to store a continually updating set of frames from the input, or a specific set of frames via the pre-fill functionality of Tex3d or cache TOPs.

Thanks,I have used texture3D, but it feels wrong in glslMat. But it is correct to use Cache and Cache Select to create 2D texture array in glslTOP. Using cache requires a lot of cacheselects, I don’t want to do this.

I saw this on the wiki, does it mean that it can be created with glslTOP?

You can create a 3d texture or 2d texture array with a glsl top.

First you need to set the glsl top to generate the extra layers. By default, what you type in the shader will write to all layers uniformly:
image

In the shader, you can access an integer that tells you what layer you’re on (w in uvw), though it’s presented as integer form.

// Refer to 3D Textures and 2D Texture Arrays
 uniform int uTDCurrentDepth;

uTDCurrentDepth is already declared, so you can just access it in the glsl top.

1 Like

Thank you,I try. But how to create cached images?

depends on what you want to cache. If you want to cache the history of a top, and you have a glsl top with depth set to 3,

then each frame you’d want to sample from layers 1->2, then layers 0->1, then finally update layer 0 with data from the live top/source.

What you’re observing with the texture3D is a feature, not a bug - I believe it stores each new frame in a successive layer, so that it can avoid updating all layers each frame. However when you access it, there is likely some CPU logic internally that shifts your lookup index to match where it’s been offset to.

I would not worry so much about the way they look in the node preview, as if they are fetching the correct point in history, consistently.

Thank you!!! I solved.