Overlapping GL objects and alpha channel

Dec 5, 2011 at 3:27am

Overlapping GL objects and alpha channel

I’m sure this is just something simple that I’m overlooking but I haven’t been able to get this to work.

Sample patcher below has two overlapping jit.gl.videoplanes with textures that have alpha channels (supplied by jit.expr). Shouldn’t I be able to see the background object (@layer 3) wherever the foreground object (@layer 2) is transparent, rather than the erase color?

Thanks,
James

– Pasted Max Patch, click to expand. –
#60467
Dec 5, 2011 at 3:38am

The lowest numbered layers draw first, so @layer 2 will come before @layer 3. When @layer2 draws, it will blend with the erase_color. When @layer 3 draws, it will blend with @layer 2 and the erase_color. FWIW, the texture loading issue to mention in the patch doesn’t exist in Max6.

#217630
Dec 5, 2011 at 3:45am

Thanks for the quick reply. If I switch the layer numbers, I can’t see the small square at all.

#217632
Dec 5, 2011 at 3:53am

You’ll need to set @depth_enable 0 for the videoplanes so that they don’t block each other.

#217633
Dec 5, 2011 at 4:08am

Thanks – adding @depth_enable 1 to both videoplanes does not change anything: I still only see the big rectangle with texture1.

I am on Max 5.1.9 (47862).

#217635
Dec 5, 2011 at 4:09am

(I guess I shouldn’t be surprised – depth_enable is enabled by default.)

#217636
Dec 5, 2011 at 4:11am

Interestingly, if I set the position of the texture2 videoplane to 0. 0. 0.001, it does appear correctly.

I thought this might be front-face culling, but that also seems to be off by default.

#217637
Dec 5, 2011 at 4:13am

Ah ha! Setting @depth_clear 1 on them does the trick, even when the position is not set. Sweet!

#217638
Dec 7, 2011 at 10:26pm

Maybe you missed this, but Wes said depth_enable 0, not 1. Otherwise you have z-fighting issues (you can google that term).

#217639
Dec 10, 2011 at 6:39am

I did miss that! depth_clear 1 was working fine on the jit.videoplanes, but after applying this to some more complex geometries that use jit.gl.mesh I was still seeing “z-fighting” amongst quads within one mesh. depth_enable 0 clears that up.

Thanks a lot!

#217640

You must be logged in to reply to this topic.