I am working with blob instancing and instance textures.
I preload all textures with a replicator and then pick random textures with a select chop and a little weird expression/ script.
The problem is the script lags behind a tiny bit during runtime which make the geo freak out.
I tried to hold the other chops used for instanicng till the index chop refreshes but that won’t work.
I tried to package the file with all img/ video files linked for easy review therefore the external link.
Tricky sections are marked with red.
in these cases it’d be best to pass in all channels via a single CHOP there being able to make sure that everything has the same length. After your Merge CHOP that assembles the u, v, width, height, and null channel, add a Pattern CHOP with three channels called index and set the Pattern CHOP’s Combine Channels parameter to “Append”. Append a Replace CHOP after and feed the second input with the channels coming from your “tex” component.
The Replace CHOP has the parameter Length where you can choose from which input to pick the numbers of samples.
The index channel might not really lag behind but maybe the Fan CHOP’s value in the tex component does not update as often as you like. There could be multiple occurances where the Logic CHOP changes but result in the same output in the Fan CHOP and by that not triggering your script.
Maybe you could calculate the index differently and then use it as a lookup to fetch the right resolutions for the textures.
To randomize a value range, my habit now is to take a Pattern CHOP and set the Type parameter to “Ramp Samples”. Set the Length parameter to your max value - in this case 99.
Next append a Sort CHOP and set the Sample Sort Method parameter to “Random”. The now exposed Seed parameter you should update whenever there is a change in the blob track.
Next add a Trim CHOP, setting the Unit Values parameter to “Absolute” and using the number of rows in your Blob Track Info DAT as a reference in the End parameter. (you’ll have to subtract 2 to account for the header in the DAT as well as the zero based counting of samples)
This Trim CHOP use as the first input of a Lookup CHOP with it’s Index Range parameter set to 0 to 99 and the second input being the Shuffled resx and resy channels from the textures.
You now have all channels that can be used in the replicator:
the index channel for texture index
the resx and resy channels for the width and height calculation
Nice thing is that they are not independently calculated but rely on the same data.
Now theoretically you could also use the id column of the Blob Track as a lookup - this way Blobs that stay alive for longer will carry the same texture.
A last little trick, instead of having to script the wire connection from your replicants to the Merge CHOP, you could use a Select CHOP setting the CHOPs parameter to “tex*/out1” and turning off the Automatic Prefix toggle. Saves a bit scripting…