blend mode, alpha, & jit.gl.texture.

hthaw's icon

hi all-
i'm reposting a similar patch to one of the past posted re: how to use alpha channels to create transparency in GL.
i'm noticed that certain faces/angles of the grid shape seem to be non-transparent and i'm not sure why, nor am i sure how to rectify this..
any thoughts?
-h

4989.AlphaDemo.maxpat
Max Patch
Rob Ramirez's icon

disable @depth_enable

hthaw's icon

Thanks Rob!

hthaw's icon

Is there another facet to this that I'm not considering? It seems like there is some other form of distortion when the object is rotating...

Rob Ramirez's icon
Max Patch
Copy patch and select New From Clipboard in Max.

if you want to draw a gridshape with transparency and back-facing polygons, your best bet is to create two identical gridshapes, set @cull_face 1 on one and @cull_face 2 on the other.
this will make one only draw front-facing polygons, and the other only draw back-facing.
you can then use the layer attribute to force the back-facing one to draw first.

FineCutBodies's icon

Rob, if i disable the depth_enable, then if i add another object to the scene then one will cover the other independently of their Z position...

i had problems with this already... do i make something wrong, or if an object's depth_enable is off then the only way i can place it to it's righ place (behind another one or the camera side) if i change the layer depending on postion every render?

thanx in advance!

Kevin

vichug's icon

Hey, fwiw setting depth_enable to 1 in Rob's example seems to give a satisfying transparency. I'm curious about this as well, i want to have a scene with several openGL objects, some of which should allow to partially see objects behind them. Is that the way to go ? With a jit.gl.texture ?

vichug's icon

So, it seems indeed to be the way to go - feed a matrix with a minimized alpha channel to a texture, which is to be applied then.