Adding another input to a jit.fx object?

Robert Alexander's icon

Hey Max Community! I'm a longtime max user but new to max 9 and jit.fx.

I've found jit.fx.co.average and see that it's able to average two input textures, and when I double click the object I'm able to see the underlying code. I'm curious if it's possible to modify a jit.fx object like this one to take in, say, three different textures across three inlets and produce the same sort of averaged output?

This operation is straightforward enough with jit.gl.pix but I'm keen to step into the world of jit.fx.

Thanks in advance for your help! I poked around on the web for a solution and couldn't find anything so figured I'd try here 🙏

TFL's icon

jit.fx objects are define objects. [jit.fxco.average] is actually a [jit.gl.slab] and you'll see how to reveal it in the linked page. slabs have an @inputs attribute allowing you to have more than 2 inlets (and you need to adapt the .jxs shader code to properly define and use these extra inputs).

You can also make a define object out of jit.gl.pix patchers saved as .genjit files. [jit.fx.brcosa] is an example of that. Here's the define message for it:

max define jit.fx.brcosa jit.gl.pix @gen fx.brcosa.genjit @inputs 1;