Search code examples
java3dtexturesprocessingtransparent

Processing 3: Transparent textures blocking others


What I try to do is fading (in and out) textures on a custom shape (with beginShape(QUADS)) in Processing 3.3.6.

The problem is, that the blocks (see following picture) cover others in a weird way:

Transparent texture blocking vision

What's even weirder is that the ground doesn't get blocked out.

In the code I'm basically drawing the ground, then I draw the blocks with beginshape and a texture.

For the transparency I call "tint(255, alphavalue)" and "noTint()".

What I'm trying to achieve is a fadeIn and fadeOut of transparency on the ground and blocks as an alternative to the more resource expensive fog (which I didn't seem to find an easy way for).

Does anyone know an easier way than tinting texture with alpha to achieve a truly transparent texture in processing?

Thanks


Solution

  • FIXED

    The problem is depth sorting.

    Basically, processing is sorting by draw order by default, but it should be sorted by depth.

    To fix this, I call:

    hint(ENABLE_DEPTH_SORT);
    

    before drawing the blocks and to save processing power, I call

    hint(DISABLE_DEPTH_SORT);
    

    after.