Crossfading between two [jit.gl.gridshape] objects - color not updating

Edward Stumpp's icon

So I looked at some old examples I had, did some editing of my own and I have this resulting patch. It uses the [jit.xfade] object to fade between two gridshapes in a [jit.world]. However, when you adjust the color of either shape it will not update until you set the shape again (hopefully that makes sense).

I have the gridshape objects set on Matrix Output2 so I so see some changes (like scale and dimensions); but I do not understand why the color would not be changing as well.

Any thought or suggestions...?

Crossfading between gridshapes.maxpat
Max Patch

Marco1618's icon

Can't help much, but I see that your patch works as expected in gl2, but it doesn't in gl3 (Preferences > Jitter > Graphics Engine), can you confirm?

Rob Ramirez's icon

This does look like some changed behavior between gl2 and glcore. The reason being due to the differences in the engines, glcolor must handle color data more efficiently. In this case every vertex of the mesh shares a single color value. In terms of GLSL, this means the value is a uniform rather than a vertex attribute. I can fix this to bring back the old behavior when matrixoutput is enabled, but I would recommend a slightly different approach to mixing shapes in this manner.

Since you are only utilizing position values from the gridshapes, you can chop all the other planes of data and pass only the first 3 planes, which represent position values, on to the mesh. This is easily accomplished by a jit.pack 1 @jump 3. You can then make a simple color crossfader using vexpr that is triggered by the same line output value you are using for the xfade.

I modified your patch to demonstrate this, see if that helps.

Max Patch
Copy patch and select New From Clipboard in Max.

Wil's icon

@ROB RAMIREZ

side note - maybe this has to do with gl2 vs glcore as well. (I thought it was jit.movie) - but happening here as well-

when I have a large audio patch open (no other video) and run this patch with DSP OFF - (as well as my own patchers using jit.movie) - getting really low frame rate when running the process-

DSP OFF

DSP on

DSP ON


Why does Audio need to be on for the frame rate to go up?

If I close the large audio patch, this process runs normal.



Edward Stumpp's icon

MARCO1618 - I do have my engine set to glcore (gl3).

Rob - Thank you for the clear explanation; I have to admit my limited knowledge with the intricacies of the engine. The additions to the patch you have made make the patch function as I thought it would. It took me a minute to full understand the expression [vexpr $f1*(1-$f3)+$f2*$f3]. You mentioned that you 'would recommend a slightly different approach to mixing shapes in this manner.' What other approach would that be? Please don't feel the need to create a whole new patch; I'd like to make sure I really learn and practice problem solving Jitter stuff. Thank you so much for your help!

Rob Ramirez's icon

What other approach would that be?

Simply the approach I've provided above, where you're only processing the 3 planes of position data from your source geometries.

@WIL, no idea, and not related to this post so please either file an issue with support or start a separate thread. In either case we'll need complete information to offer any suggestions.