Texture 3D TOP cache behavior

Hi, I saw that this is the default cache behavior for the Texture 3D TOP:

“The Texture 3D TOP replaces one slice of its 3D data with its input every frame. When it has filled up all of its slices it wraps around and starts overwriting the oldest slice.”

What I’d like it to do is: when the cache is full, remove the oldest slice to make space so the newest slice is appended.

I’m basically interested in getting a moving window of the last N frames of video device input that can be accessed as a sampler3D in a GLSL TOP.

That’s what the Texture 3D already does. Since moving all of the frames around is very expensive, the location of the ‘newest’ frame isn’t going to be at W=0, but instead at a ‘depthOffset’ value given to you in the TDTexInfo struct for that input in the GLSL TOP

Thanks, that makes sense!

Hey, Sorry to dig up this old thread. I am having trouble finding the same information for a GLSL MAT. TDTexInfo only seems to exist for GLSL TOPs

The documentation says:

When using sampler3D created using a Texture 3D TOP, it can sometimes be useful to know which slice is the ‘newest’ slice in the array, when using the Texture 3D TOP as a circular cache. The P-coordinate location of where the newest slice will provided by a uniform named the same as your sampler, with the suffix ‘POffset’. For example if you have a uniform named sColorMap, there will be uniform named

uniform float sColorMapPOffset; // P offset to newest slice in sampler3D named sColorMap
TouchDesigner specific Uniforms

I have a Sampler 3d called sTrail. I can sample from it in my vertex shader of my GLSL MAT. However trying to use the uniform sTrailPOffset it is undefined. Is there anything else I need to do?

Yes it’s a little inconvenient not having the uTD*Info stuff in GLSL Materials. It’s been a while since I did this, but I think I had a 1x1 GLSL TOP whose single purpose was to take a Texture 3D TOP and paint uTD3DInfos[0].depth.z into the one pixel output. Then I either did a TOP to CHOP with this-frame enabled (not next frame) and passed the value as a uniform to the MAT. Or I passed the 1x1 pixel as another sampler onto the MAT and read this sampler as a texture to get that important offset value.

Update: don’t follow my instructions above. Instead try to use the uniform float sColorMapPOffset; way

2 Likes

Cheers!
Seems a bit like a workaround but it works well.
I am still wondering though did I missunderstand that part of the Documentation or is it just not working properly?

For that uniform you need to declare it yourself. If declared then I’ll fill it in. I’ll update the docs to make this more clear.

Oh cool I think I understand now. This new way is better :slight_smile: