3D Models alpha channel not working properly, jmonkey version 3.1


Probably you were relying on alphaTest and now you must use alphaDiscardThreshold.

alphaTest was removed because it is deprecated in OpenGL.


Even if it is deprecated, why did it got removed? it s still working fine by me! I had better result then using the alphaDiscardThreshold which show my sky arround the leaves and you can see through other leaves.


What i am talking about


If you get a different result then the values are not comparable. You must have had a different alphaFalloff set than whatever alphaDiscardThreshold you are using.

…else you were just getting lucky with sorting.

Otherwise, they are functionally no different.


I ve never use the alphaFalloff and it was working fine

Material My Material : Common/MatDefs/Light/Lighting.j3md {
     MaterialParameters {
        HighQuality : true
        VTangent : false
        UseAlpha : false
        VertexLighting : false
        DiffuseMap : Repeat Models/Environment/Pine/Branches0014_1_S.png
        Minnaert : false
        SteepParallax : false
        UseVertexColor : false
        UseMaterialColors : false
        PackedNormalParallax : false
        EnvMapAsSphereMap : false
        SeparateTexCoord : false
        LowQuality : false
        HardwareShadows : false
        WardIso : false
        ShadowMapSize : 0.0
    AdditionalRenderState {
      DepthWrite On
      AlphaTestFalloff 0.0
      Blend Off
      Wireframe Off
      FaceCull Back
      DepthTest On
      ColorWrite On


I found out when I set my leaves to opaque everything work perfectly


Do you mean putting them in the opaque bucket?

…that makes no sense that it would work better unless you have some other stuff in the wrong bucket.

Can you show a picture of what’s happening?


Do you use custom geometry comparators by any chance? If so then maybe one of them is backwards.


I don’t know what it is(geometry comparators), but what i can tell is when i place the leaves in the opaque bucket they all come out fine! So something is clearly wrong somewhere or I just don’t get how that stuff work.


I have to tell my geometry are done on blender with the default settings and i use the ogre export for blender.


This might help explain how things work:


From what you wrote then there is a mistake somewhere, and the engine doesn’t behave as it should, the seconde exemple with the Z-contention where it draw alpha first then opaque is exactly what i get if I put the transparent model in the the transparent bucket. But when i put all of then in the opaque they behave as the first exemple with almost no glitch. (or none at all)

by the way: There is some bug using the Material Lighting Definition, when you check use ColorWrite and then uncheck the model just bug out. You have to manually remove the line inside the definition.


If you can then it would be good to put together a simple test case (maybe with textured quads or something) that shows the issue. There is a high likelihood that a simple test case will work properly and then you can start making it more like your real code until it breaks similarly.

Else at least we will see exactly what you are running.


I will test it once I get more free time, School started this week. But here is a picture of the working model.

I will try to find time to make the test case with a quads, I always wanted to try to make an ocean lol (With giant wave ^^)


I for some reason didn’t see this picture before. In this picture, the leaves are draw before the tree trunk… which means the tree trunk must be in the transparent bucket if the leaves are in the transparent bucket.

If moving the leaves to the opaque bucket fixes this then it’s just a matter of luck, I guess.

Is each leaf a separate object? If not then they will always self-occlude.

Actually, if you put them in the opaque bucket then it might look like they are working better but only because the background will be black when they are drawn. The sky is drawn after the opaque bucket. Put the leaves back in the transparent bucket and then remove the sky… I bet they will look “fine” then, too.

And if you are ok with the effect then you can fix it in the texture (or hack the shader) to not have any partial transparent pixels. Basically, if a < 1 and a > 0 then mix the color with black and set alpha to 1. I could explain how I’d do it in photoshop.


100% of the model is inside the opaque bucket, the trunk, leaves and the base of the model.

The leaves are a single object so it save CPU time or GPU. At the moment every time I do the same setting for each material i get the exact same result. So It may be luck, but doing the exact same thing bring the exact same result.

I think we should leave this post for now and see if some one else get the exact same problem. Else if no one occur to have it, it would mean I actually did something wrong somewhere!


Put the leaves back in the transparent bucket and then remove the sky. I suspect when you think it looks ok it’s actually because the bleeding is from the background which is black before the sky is rendered.

In your latest pic, you are looking top down which will cause the objects to sort differently and chances are your leaves are rendered bottom up (back to front when looking down from the top).


I ve set the bucket to transparent and remove the sky and we can see through the trunk.


Actually this bug seem to be present in both context… So the sky is the reason we can see blue color around when using transparent bucket. Althought using the transparent bucket make the trunk draw over everything.


If your trunk is in the opaque bucket and your leaves are in the transparent bucket then the trunk will be drawn first… then the leaves.

However, the bottom leaves are FIRST in your mesh so they will be drawn first. Any partially transparent pixels will show the trunk instead of the leaves behind them. Is this what you mean by “trunk draw over everything”.

Else your trunk is also in the transparent bucket.

At this point, you need to make a simple test case because there are too many variables that I can’t see.