Are blended textures only transparent on one side?

Apr 21, 2010 at 5:15am

Are blended textures only transparent on one side?

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

– Pasted Max Patch, click to expand. –
#49896
Apr 21, 2010 at 3:04pm

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!

– Pasted Max Patch, click to expand. –

`

#179188
Apr 21, 2010 at 9:53pm

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.

#179189
Apr 22, 2010 at 1:10am

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). …”

#179190
Apr 22, 2010 at 3:09am

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.

http://cycling74.com/forums/topic.php?id=7428

– Pasted Max Patch, click to expand. –
#179191
Apr 22, 2010 at 3:53am

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

http://foolskool.com/max/archive/alphaordering.zip

#179192

You must be logged in to reply to this topic.