Using Vizzie Kalider texture output in shader code issue?

Jon Williams's icon
Max Patch
Copy patch and select New From Clipboard in Max.

The 4 jit.pwindows in this patch show the expected results, both the Kalider-direct output and the "txKalid" texture output show the noisy Kalider colors. But, the jit.world window showing the 3d output of the "colorCrossfader" shader is not showing those Kalider texture colors, even though coded to do so.

This line from the Fragment Program:

color = mix(txKalidVec, color, colorOffsetScale);

And this line:

//color = mix(txChixVec, color, colorOffsetScale);

output the exact same colors (crossfade results) when you swap which line is commented out. In other words, it seems to me like the "txKalid" texture reference in the shader code is pointing to the "txChix" texture's memory location instead of its own memory location. Could that be correct? Or, where is the mistake I'm missing?

Edit: moved thread to Jitter category. If you remove the @shader attribute from one of the gridshape objects, the "default shader" for that object does a 50/50 "blend" of the two @texture inputs in jit.world, so I think I should be able to control that "blend amount" in my custom shader with the "colorOffsetScale" parameter value. But, not working. Is it me? It's usually me.

Rob Ramirez's icon

in your shader patch you are not declaring your 2 textures and binding them to a tex unit. simply replace this line:

<param name="tex0" type="int" default="0" />

with these 2 lines:

<param name="txChix" type="int" default="0" />
<param name="txKalid" type="int" default="1" />

This declares your 2 texture uniforms and binds them to the first and second texture units. Note that these names in your shader are not related to the names of your textures in the patch. The way you specify which texture goes to which unit in the patch is by the order they are listed in the texture attribute.

Jon Williams's icon

It seems my question was based on a false assumption I made early on and never questioned. It only appears as if you can pass a list of texture names to a gridshape object using the @texture attribute in the sense that you can probably pass a list of any number of string values with the @texture attribute, but only the first list item is checked for a match with a named texture in the patch and the rest of the "texture attribute input list", if any, is ignored.

The rest of the story is I can still generally do what I originally imagined, but I have to implement a form of the behavior a different way, using a jit.gl.pix object to (pre) combine the two textures into one texture that then gets passed to the custom "colorCrossfader" shader via the gridshape @texture attribute.

Rob Ramirez's icon

not sure what you're saying. your patch is fine, and your assumption about passing a list of texture names to the texture attribute is correct. however in the JXS param tags you need to bind the textures as I've described. after doing that your patch should work as expected. if the assumption is that named textures will auto-bind to texture uniforms in the shader of the same name, then no that functionality does not exist.