Transparency issue with jit.gl.gridshape

Jul 24, 2013 at 9:41am

Transparency issue with jit.gl.gridshape

Hi guys,

I am in need of a little help!

I have created a large 5-sided cube (with a 6th, front side to be added) out of 5 flattened cubes from jit.gl.gridshape objects, and have placed a sphere inside which bounces about, reporting collisions with each face of the cube as it hits them. I am attempting to make each face transparent so that the sphere inside can be seen, but when it hits a face, I wanted that face to flash a certain colour, then return to being transparent.

I have managed to work out the collision reporting, but I am stuck on this one transparency issue. I have searched about the forums and the only thing I’ve found is how to make a whole cube from one jit.gl.gridshape object transparent, which isn’t what I’m after as I would want to trigger each face separately. Basically just need some idea on how to make a flattened cube shape transparent so that the black areas are see-through, but colours become visible when collisions occur.

I have posted the patch, hope it’s okay to read. Thanks in advance for any assistance given!

<code>

– Pasted Max Patch, click to expand. –

</code>

#257022
Jul 24, 2013 at 12:40pm

for transparent objects, you must set @depth_enable 0 @blend_enable 1.
you then want to make all the transparent objects draw last, by setting @layer to some high value (eg 100)

you can then control transparency with the alpha value of the the color attribute.
you probably don’t want to attach a jit.gl.material to your transparent objects, because that complicates things and is probably unnecessary.

i would also use jit.gl.gridshape @shape plane instead of cube for your walls, however if you need to use cube, i would turn on back-face culling (@cull_face 1).

try those things out, and let us know if you still can’t get it working.

#257036
Jul 25, 2013 at 5:35am

Awesome, it works! Made the changes you suggested as well as trying out different blend modes which was suggested by somebody in my post to the wrong (Max/MSP) forum, combining the two solved the issue!

Thanks a lot for the help.

#257096

You must be logged in to reply to this topic.