Transparency jit.gl.model - jit.gl.gridshape

Vincenzo Perna's icon

Hi, I've already searched through other topics, but I didn't find a complete answer to my problem.
I'm creating a project in which 3D objects must appear alternately, but I can't manage the transparency of the objects jit.gl.model and jit.gl.gridshape in any way. Ideas?

Rob Ramirez's icon

transparency requires @blend_enable 1 and @depth_enable 0 on the transparent objects. you likely want to set @layer to some value higher than the default of 0 so they draw last. You can then control opacity with the alpha value of the color attribute. Post a patch if that's not working.

Vincenzo Perna's icon

With jit.gl.gridshape it works, but applying a texture on the object when I rotate it on the y axis changes the size of the texture, is it possible to dynamically manage the alpha of the color attribute?

On the jit.gl.model object it doesn't seem to work, applying the attributes @blend_enable 1 and @depth_enable 0 there is also a loss of samples of the 3Ds object that is loaded inside.

Project jitter.maxpat
Max Patch

Rob Ramirez's icon

Ok with jit.gl.material attached to a jit.gl.model it's a bit more complicated. First for transparency with jit.gl.material you need to zero out the alpha value of all the material color components (mat_specular, etc) and then you can use mat_diffuse alpha to adjust overall transparency.

And when using with jit.gl.model to override the model file's material, you must set @material_mode 0. You may also want to use @cull_face 3 which will automatically draw back faces before front faces, which is useful for drawing shapes with transparency.

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

Vincenzo Perna's icon

Thank you, you solved the previous problems, I have another question: If I add a background with jit.gl.environment, managing the alpha of the 3D objects obviously the layer of the object superimposed on the background remains, even when the alpha value is 0. Is there any way to not make this happen? That is, I would like the object to become totally transparent.

Rob Ramirez's icon

again, post a patch that shows what you are seeing and we'll do our best.

Vincenzo Perna's icon

Here is an example patch.

example.maxpat
Max Patch