[SOLVED] Another Transparency Problem (SDK 3.1)

Hi guys, i am back with another trouble with transparency :kissing_smiling_eyes:

As i wanted to try Lemur, i did realise that i was on 3.0 sdk, so i installed 3.1
After installing and making Lemur working, i did transfert rest of my test codes

Unfortunatly a spatial transparency doesn’t work anymore (which was working on 3.0), looks like alpha channel do make color transparent but not the 3D object.
After checking everything, changing every params i could, i did put on it the material of another spatial who is transparent and working, and still no success… so i am lost, what should i try ? can it be a problem with the 3D model?

2 spatial, imported .obj, same material, both on transparent bucket :


There isn’t really more than my description, except a light and the skybox.

import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Spatial;
import com.jme3.texture.Texture;
import com.jme3.util.SkyFactory;

public class Main extends SimpleApplication {
    private Spatial sphere,hexa;

    public static void main(String[] args) {
        Main app = new Main();

    public void simpleInitApp() {


        Material mat_test = new Material(
           assetManager, "Common/MatDefs/Light/Lighting.j3md");
        mat_test.setColor("Ambient", new ColorRGBA(0.2f,0.2f,0.8f,0.4f));
        mat_test.setColor("Diffuse", new ColorRGBA(0.2f,0.2f,0.8f,0.4f)); 
        sphere = assetManager.loadModel("Models/Earth/Planet2.obj");  
        hexa = assetManager.loadModel("Models/untitled2.obj");
        hexa.setLocalTranslation(0, -2.5f, 0);
        //** Must add a light to make the lit object visible! */
        AmbientLight sun = new AmbientLight();

        * Galaxy Box
        String neb = "Textures/Sky/";
        Texture back = assetManager.loadTexture(neb+"Gal_back6.png");
        Texture bottom = assetManager.loadTexture(neb+"Gal_bottom4.png");
        Texture front = assetManager.loadTexture(neb+"Gal_front5.png");
        Texture left = assetManager.loadTexture(neb+"Gal_left2.png");
        Texture right = assetManager.loadTexture(neb+"Gal_right1.png");
        Texture top = assetManager.loadTexture(neb+"Gal_top3.png");
        rootNode.attachChild(SkyFactory.createSky(assetManager, left, right, front, back, top, bottom));

    public void simpleUpdate(float tpf) {

    public void simpleRender(RenderManager rm) {
        //TODO: add render code

So i don’t know where it come from, but like i said, exact same thing is working on SDK 3.0 :

What if you replace your models with some JME primitives like box and sphere?

Would probably work, i mean, there’s high chance the problem come from the hexagon model :sweat_smile: but wondering why on sdk 3.1 and not 3.0.

I’m noob in everything with 3D but if i remember correctly, the hexagon was a .dae i opened with blender, just recentered and exported as .obj, don’t know if this can have any consequence ? since if i am not wrong, dae is a source of problems.
While the sphere is just made with blender.

And about primitive, first i did want to create the hexagon with jm3 but did abandon, was easier to find one.
I might check for a non-dae one, or just retry creating it.

There may be a bug. There may be something situational that is just triggered at a different time on 3.1 than on 3.0 and you would have hit it eventually if you stood in the right spot. Any number of things… would all be speculation until we drill on why transparency is not working.

If the primitives also don’t work then it lets us look at something else. If the primitives work then we can start looking at what’s strange/different about the hexagon.

I understand, thanks
i’m checking all this right now, but i probably did something wrong with the hexagon, SDK 3.0 probably did accept my error, and 3.1 is more strict :sweat_smile:

Ok after loading few primitives (all works) and a random hexagon model, a way more complex one but worked too. I still did find the problem, it was my fault.
I did randomly compare .mtl files by curiosity of both hexagon, and it look like the one i use have 2 materials, no idea why, didn’t touch anything in blender related to materials since i don’t know how does it works and i didn’t need to texture it.

But it looks like this:

newmtl material
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.712157 0.705882 0.696471
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

newmtl material_0
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.436078 0.426667 0.483137
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

No idea what that mean but tried to delete last one to see what it does, and conclusion is that i am stupid sorry :laughing:
If i understand correctly i should have in some way set both material to make it works, only one on colored alpha made it looks like alpha wasn’t working.
But haven’t read about this kind of thing yet, it is next chapter.

I have deleted one material from .mtl to keep one face and it is working now, but don’t know if it is the right thing to do ?

And well, looks like SDK 3.0 didn’t care about one or two materials from .mtl for setting colors, SDK 3.1 cares, which sound like an improvement i believe.

Just to understand what was the issue, you hexagon is double sided, and ech feace had a different material?
Seems weird to me anyway looking at your test code, since you replaced that material…
Also you’d have to turn off back face culling to have this issue…

Yep sorry the issue came from the model, i deleted first material definition from .mtl and renamed the 2nd, it was the top face and i don’t need other face.
transparency working correctly after that.
I hope this rough delete won’t create any issues ? (i mean i deleted with notepad :kissing_smiling_eyes:)

Don’t know anything about 3D modeling, don’t know if it is normal to have 2 material in .mtl
But after research on forum, old posts but, looks like multi-material isn’t supported ?
In some way, i believe something did change about it from 3.0 → 3.1

Anyway, yes, i suppose with 3.1 sdk, and the simple code i did post, color was set on one face but not the other one.

About culling, yes one face should have been invisible, but it is a flat hexagon, like a quad geometry in jm3.
Maybe it was the back face who was transparent+colored and in someway it mixed up with front face material, they fusioned to a badass blue opaque hexagon ? (did turn camera around both face were the same)
And when on alpha 0, hexagon is black, the back face was probably invisible, i just did check to make sure it’s black from both face… strange :grin:

oh wait it is plain blue on alpha 1 too from both face… no badass fusion then! RGB does set to both material, but not A ? that would explain the issue i guess.
edit: oops forgot about culling… doesn’t really explain the issue then :sweat_smile:

Did you try to set a Material in code?
Use Unshaded.j3md, with blue "Color" and additionalRenderState with BlendMode.ALPHA, DepthWrite(false), and QueueBucket.Transparent

Which is bad except under very specific circumstances where you know you will have nothing else in your scene rendered after.

Hm? depth write true with semi-transparent objects? Okay, didn’t know that. Thanks for the info.

I will post another strange transparency question soon: Tried to use a particle system with ALPHA blending (becaus ADDITIVE blending is not what I want for my fire) and it didn’t work (renders black quads). Could post the full code too - it’s a modified TestPostWater.java with a little fire. But will open another thread for it…

If you don’t have depth write on then anything drawn after that object won’t interact with its depth (obviously) which can look very strange if it’s a normal object in the scene. Stuff drawn partially behind it will just write right over it.

Hm, okay. I usually disable depth write for all the stuff in the QueueBucket.Transparent. But now that you say it, I can imagine certain specific scenes to look better with depth write enabled in that QueueBucket.