gl2 vs gl3: single plane matrix to gl.slab

Jean-Francois Charles's icon

Hi,
I've sometimes fed a float32 one-plane matrix to a jit.gl.slab. My reasoning was that it would save some data duplication to avoid a conversion to a 4-plane matrix.
It turns out that this doesn't work anymore with gl3: the one-plane matrix is then treated as a red plane.
I could just convert my matrices to 4-plane (jit.pack or jit.matrix)
But would someone point me in the right direction to massage the gl3 version of the shader in order to let the GPU use a single plane input on the internal RGB or RGBA?
Here is a simple example working in gl2, but not in gl3.

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

Thanks!

Federico-AmazingMaxStuff's icon

You could sample the input matrix (which gets converted to a texture in jit.gl.slab) lile this:
vec4 myMatVal = texture(myMat, texcoord).rrrr;
This would work in the shader I believe.
Anyway why are you passing matrices to jit.gl.slab?
It could be more performant to make the calculation in jit.gen if you are working with matrices.
Passing a one-plane matrix to the GPU is not much more efficient than passing a 4 planes matrix.

Jean-Francois Charles's icon

Great, thanks for that! You made my day!
(I wanted to avoid copying a 1-plane matrix into 4 planes of a 4-plane matrix.)