jit.gl.mesh self transparency problem

esnho's icon

Hi,
I'd like to play with geometry and the mesh object but, I really need transparency of rendered "objects". But as you can see from the attached patch and image, it cannot render transparency properly, it doesn't render at all...

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

Thank you.

transparency.png
png
diablodale's icon

transparency in OpenGL (the technology Max uses) is not automatic and perfect. It is just the way that OpenGL is designed and implemented.

A large part of getting transparency to work like you probably want it to work...is to change the drawing order. You need to draw the items furthest away from the camera first, and then draw them in order moving towards the camera. This includes things like the mesh. In your example, the mesh is drawing in an order which makes the transparency not able to perform well. If you rotate the mesh using @rotatexyz -5.469016 -133.987686 55.153473, then the transparency behavior is better. This is because in that rotation, OpenGL is drawing the segments of the mesh furthest away from teh camera first.

This is a normal part of learning OpenGL. And dong self-transparency is a particularily tricky part.

Andro's icon

Try messing around with the @blend enable and the @depth enable settings. I plug my jit.gl.model object into jit.gl.node and then send that to a videoplane. This lets me keep the transparency and makes it easier (for me at least) to decide the drawing order of multiple objects.

esnho's icon

Thank you very much Diablodale, I've already met the render order issue, I did not think it was one of those cases.

I've solved with a simple GEN patch.

Andro, I think you didn't get the problem, with other objects the alpha is ok, but, I was looking for self transparency.

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

Here is the modified patch.

diablodale's icon

The patch you posted might work for the specific orientation of your sphere. However, if you rotate it in any way, it is likely that the vertices will no longer enable you to just reverse their order (using your gen sampler). To solve the general case that works all the time, you would need to do sorting. And...sorting can be non-trivial because of the many cases of overlapping and slanted polygons.
Its a fun problem to tackle. :-)

esnho's icon

Yes, I know this, ordening in this complex system(for me) can be a problem, I've already did some fake 3D or 3D ordening in processing, but it was a system totally generated by me and it was a simple system.

I think I will live with this issue and show to the camera only the right face.

I did this patch just to try, maybe I won't use the GEN order reverse and I will implement some kind of reverse on the rotatexyz degrees.

esnho's icon

Hey, I've found a workaround just on this forum posted by Rob Ramirez, I'll try soon.
https://cycling74.com/forums/blend-mode-alpha-jit-gl-texture