Making Alpha channel work in jit.gl.multiple while light_enable is on

little_wizard's icon

Hello everyone, i'm having a problem using jit.gl.multiple. I'll explain it.

Take a jit.gl.gridshape bound to a jit.gl.multiple (through left jit.gl.multiple outlet):

  1. If jit.gl.gridshape has @lighting_enable 0 and @blend_enable 0, then I can change RGB color array only with jit.gl.multiple, not with jit.gl.gridshape (Alpha channel won't change);

  2. If jit.gl.gridshape has @lighting_enable 0 and @blend_enable_1, then I can change RGBA color array only with jit.gl.multiple, not with jit.gl.gridshape;

  3. If jit.gl.gridshape has @lighting_enable 1 and @blend_enable_0, then I can change RGB color array only with jit.gl.multiple, not with jit.gl.gridshape (Alpha channel won't change);

  4. If jit.gl.gridshape has @lighting_enable 1 and @blend_enable_1, then I can change RGB color array only with jit.gl.multiple, and A channel only with jit.gl.gridshape.

jit.gl.multiple @blend_enable appears to be useless, i can't see any variations changing it.

Case 4. shows that is possible to work with both light and alpha channel activated. The problem is that I want to change A channel with jit.gl.multiple and not with jit.gl.gridshape while having light_enable 1. If I could modify alpha channel with jit.gl.multiple while light_enable is 1, it would give me more possibility to change it individually on each copy made with jit.gl.multiple, unless to do it globally. I can't figure out how to do it. I hope someone can help me.

Rob Ramirez's icon

please provide a patch and i'll take a look

little_wizard's icon

I'm not sure if what i'm asking for is something possible. Here the patch.

The alpha channel with jit.gl.multiple problem.maxpat
Max Patch

Rob Ramirez's icon

ok I understand what you're attempting. It looks like the default shader generator is ignoring the instance color alpha (as you've discovered). I would consider this a bug, and I'll file a ticket to get it fixed. I think if instance colors are provided, it should take alpha from those instance colors.

For now you can get what you want by using a custom shader rather than the default shader. I've updated your patch with this custom shader. Keep in mind that this means lighting is baked into the shader (so the lighting_enable toggle no longer has any effect).

The alpha channel with jit.gl.multiple problem.maxpat
Max Patch


little_wizard's icon

Does this shader require Max 9 to work properly? Because I'm using Max 8 and I can't get it to work

Rob Ramirez's icon

no, but max 8 does not support embedded shaders, so you need to save the shader to a separate file and load it via the file attribute : jit.gl.shader @name multshade @file multshade.jxs

multshade.jxs
jxs 5.96 KB


little_wizard's icon

I tried to copy the text inside the jit.gl.shader you wrote in the first file, save it as .jxs with notepad++, and then read it in the patch with jit.gl.shader but apparently it didn't work. I'm not familiar with written shaders at moment, but i understand that it's currently the way to fix the problem. You said that it could be a bug to fix. Well, the same issue, it seems to me, happens with jit.gl.mesh too: when I give @lighting_enable 1 and blend_enable 1 on jit.gl.mesh, it reads correctly alpha channels only trough @gl_color (that is global), but again alpha channel gives problems when given through jit.gl.mesh color array inlet when @lighting_enable 1 and blend_enable 1.

Rob Ramirez's icon

I see the same bug with jit.gl.mesh. thanks for the report, will note that on the ticket.

To make the custom shader workaround work in Max 8, download the "multshade.jxs" file I attached to my second reply to you.

little_wizard's icon

Yes, it works. Thank you Rob! lighting + blend + jit.gl.multiple single shape control. I knew it was possible because case 4. of my first patch showed that possibility. I also appreciate your will to report jit.gl.multiple and jit.gl.mesh issue and hope they fix the problem.

little_wizard's icon

If they fix this problem both on jit.gl.multiple and jit.gl.mesh, a step further would be to make everything work while jit.gl.material (and jit.gl.pbr too?) is attached to them. At moment it doesn't work.

Devs have to take care of that alpha problem which is spread on some jit.gl objects and/or their connections.

In the meantime I'll learn how to make my own shaders, starting from this input you gave me, Rob.