Stencil mask


I am currently trying to create a couple of low-poly trees for use in jMonkey. The idea is to model the trees with just a few polygons and then mask out the branches and leaves with an alphamap. I do this by adding an alpha channel in the texture and an alpha state on the node.

In principle the method works, however I have run into a problem. The Z-buffer is updated for each pixel regardless of whether the alpha is 1 or 0. Because of this, pixels on polygons that are located further away than the transparent segments of the trees and which are drawn later are not visible.

Does anyone know of a method to disable Z-buffer updates with a stencil- or alpha mask?



If you render the branches that are most far away first this should be less of a problem. For normal objects in jME you can use the render queue for this:


Of course your branches might be constructed or drawn in a way this will not help, in that case let's hope someone knows an answer to your questions.


Thank you!