Overlapping GL objects and alpha channel

Jadie Rage's icon

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?

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

Thanks,
James

Wesley Smith's icon

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.

Jadie Rage's icon

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

Wesley Smith's icon

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

Jadie Rage's icon

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

Jadie Rage's icon

(I guess I shouldn't be surprised - depth_enable is enabled by default.)

Jadie Rage's icon

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.

Jadie Rage's icon

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

vade's icon

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

Jadie Rage's icon

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!