Problem with transparent textures

hi people, hi have a problem, im tring to import a model with a transparent texture.

im importing the model from a blend file, im not generate a xml with ogre exporter.

here is an screenshot of my model in blender:

im tried to use it with a .j3m material. this is the code:

Material materialArbusto : Common/MatDefs/Light/Lighting.j3md {

Transparent On

MaterialParameters {
    DiffuseMap : Models/arbusto2/textura/alpha channel.png
     UseAlpha : true
    AlphaDiscardThreshold : 0.5
    UseMaterialColors : true
    Ambient : .5 .5 .5 .5
    Diffuse : 0.7 0.7 0.7 1
    Specular : 0 0 0 1
    Shininess : 16
}
AdditionalRenderState {
  Blend Alpha
  AlphaTestFalloff 0.50
  FaceCull Off
}

}

but my model is all transparent(invisible). here is an screenshot:

i tried set the material to my model using a code like this:

Spatial modeloSpatial = assetManager.loadModel(Models/arbusto2/arbusto.j3o);
Material mat1 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat1.setTexture(“ColorMap”, assetManager.loadTexture(Models/arbusto2/textura/alpha channel.png));
mat1.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
modeloSpatial.setQueueBucket(Bucket.Transparent);
modeloSpatial.setMaterial(mat1);

but the result is the same.

i hope somebody helpme thank you.

So…
AlphaDiscardThreshold : 0.5
UseMaterialColors : true
Ambient : .5 .5 .5 .5

Ambient has an alpha of .5 which tends to indicate that anything not directly lit will never have more than 0.5 alpha… and yet pixels are discarded if they have less than 0.5 alpha.

…could be relevant. Maybe.

…though that doesn’t explain the second part. What happens if you don’t turn on alpha blending?

if i don’t turn on alpha blending, all model is on black

What al i doing wrong?

@eypidemik said: What al i doing wrong?

I don’t think we have any more ideas… it’s something wrong with something that we can’t see.

For example, I presume if you replace your model with a JME Box mesh + Geometry that everything will work. Which would at least narrow it down to something about the model’s setup.

i see a problem when i try to import my model:

C:/Users/ivan/Documents/blender/texturas invisibles/textura/alpha channel.png (Flipped) (Mipmapped)

so… the problem is in blender?

sorry i renamed my texture. false alarm

ok i done it, i modified material configuration in blender, but now i have a new problem, i can see a transparent cuad around my model.
here is an screenshot

What can cause this problem?

Well, it looks like the alpha discard threshold is not set… but it is also concerning that it’s blocking your terrain which implies that your terrain is somehow in the same render bucket.

The tree should be in the transparent bucket and your terrain should be in the opaque bucket.

1 Like

thank you, is done, but now i have a last problem, i can see my tree only in one face of my plane, in the other face is invisible.

may you help me?

really, thankyou for all your answers

You need to disable face culling on the foliage.
material.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);

2 Likes

thankyou very much, im like jmonkey engine, and im like this forum and comunity, when I have a problem, always help me, really thanks to @nehon, @pspeed, @normen, @wezrule, @zarch, and all people of ths comunity.

1 Like

has certainly my problem is fully solved

Marked thread as resolved for you :slight_smile:

ok sorry, but is not fully solved, when a light shine in front of my model, all is fine. But when a light shine behind my model, the frontal face is iluminated and the face of behind is all dark,

@eypidemik said: ok sorry, but is not fully solved, when a light shine in front of my model, all is fine. But when a light shine behind my model, the frontal face is illuminated and the face of behind is all dark,
Well, that's because you use a simple quad. The quad has normals pointing in one direction only. The best thing to do in that case would be to have a mesh made of 2 quads pointing in the opposite direction.