jit.gl.multiple and layers managing

ponti00s's icon

Hi,

I'm using a png pictures with transparent background. Normally I can manage it in "Z "order by [jit.gl. layer] object. In this way everything works perfect. But this time I need to multiplicate a lot of picture instances, so I've took a [jit.gl.multiple] object. I'm loading my png as a texture and drawing it onto [jit.gl.gridshape] object which is multiplied. Position of the instances is managed by [jit.bfg], so often some instances overlapping each other. When this happens, the instance which was drawn later by GL appears "on top" the previous drawn, so the result is, part of the previous picture is obscured by "transparent" background of the next one. This not affect the background texture drawing because It's on the different layer.
The possible solution would be, if will be possible to use "layer" as a one of the glparams in the [jit.gl.multiple] object, unfortunately such feature is not implemented in it.

Is there some shader I can use inside of jit.gl.multiple, which is capable to fix this?
Maybe I'm using a wrong method to achieve this kind of animation?

Please help :)

Sprites_test.maxpat
text/plain 29.88 KB
Patch illustrating the problem

png for multiplication

png as a bacground picture


testcase's icon

not sure how this will work with the final idea you are working on but one solution would be to turn off the depth_enable attribute of the jit.gl.gridshape object.

ponti00s's icon

Sure, I forgot to describe what I want to get on the video image :)
So, my goal is to make a kind of two dimensional (motion) picture, taking advantage of transparency of each instance of the texture, exactly as layers in Photoshop do.

Thank you testcase, I've tried turn off depth_enable attribute on jit.gl.gridshape, but didn't help. I've made it also with jit.gl.multiple, and finally with jit.world in different combinations, but everything behave the same.

I'm pretty sure the issue is somehow connected with a GL layers concept, but no idea how to solve it.
Now I'm trying to experiment with particle generators instead of jit.gl.multiple.

ponti00s's icon

Sorry testcase, I've looked closer, and I discover a typo in a mesage I've made in a patch.
Your solution works great! :D
Thank you very much!
The problem is solved.