Are blended textures only transparent on one side?

T. A. Gambarotto's icon

New to Jitter. Are blended textures only transparent on one side? See below.

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

Bas van der Graaff's icon

Nope. Problem is in this case that you're effectively drawing 2 objects in 1. When you draw semitransparent objects, the use of the depth buffer becomes tricky, because you can't really decide at what depth the previous object was drawn. In this case, if the front object is drawn first, the depth is set even though the pixels are transparent, and parts of the second object behind the first won't be drawn at all.

So if you want to handle this correctly (at least the way it happens in games etc), you should draw all the solid objects first (they use depthbuffer normally), then draw all semitransparent objects from back to front (with depthbuffer writing off, sorted manually, a PitA).

An alternative (which might be sufficient when you're making some nice visual collage or art crap) is to not write to depthbuffer at all when drawing semitransparent objects. How? Forgot the command, probably somewhere in jit.gl.sketch. But this will obviously not give physically correct results.

Try switching the gate in this edited version of your patch to draw them the other way around. Good luck!

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

`

T. A. Gambarotto's icon

Thank you for your answer! I guess your suggestion of sorting objects back to front would work best for me in this case, although it makes for a lot more work, and I am lazy.

marleynoe's icon

Hi there,

I am also fighting with this problem at the moment. Would you mind showing an example of the technique described below (or some other source of information on how to do this)? If I understand you right one would first have to set depthbuffer 1 (to jit.window), draw all solid objects (e.g. using jit.gl.sketch), then set depthbuffer to 0, draw all half-transparent objects, and then render this (bang to jit.gl.render)?
-However, sending a "depthbuffer" message to jit.window re-builds the OpenGL window (causing a flicker).

Any help/hint would be appreciated! :)

Best,
Marlon

"...So if you want to handle this correctly (at least the way it happens in games etc), you should draw all the solid objects first (they use depthbuffer normally), then draw all semitransparent objects from back to front (with depthbuffer writing off, sorted manually, a PitA). ..."

T. A. Gambarotto's icon

I don't think you have to reset depthbuffer. Just set it to 1 and draw all your objects (blend_enable 1) back to front, whether they are transparent or not. See attached patch.

As an aside to anyone finding this thread, I found the following thread useful for what I have been working on-- you can use the method described at the bottom to get transparency in a 3d object.

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

T. A. Gambarotto's icon

Here's a solution based on above mentioned thread with transparent planes and solids: