Why are my tree model's leaves transparent?

Hello mates! I am very new to JMonkeyEngine (Only been using it for a week or two) and I have been trying to import a blend of a tree into my game. Each time I do so (I have tried with MANY different trees), the leaves are always too transparent (They look like tinted glass). It doesn’t seem to be intentional as the renders on Blender don’t show the leaves to be really transparent at all. Is there any way to fix this little problem? I would like to use this model: http://opengameart.org/content/konserian-swamptree but any model I use shows the same problem. Thanks for all your help mates!

Is this only from a distance or also close up? Cause due to the way mipmaps work your smaller ones are getting mroe and more transparent.

It is constant. I can be as far away as I can or I can be clipping the tree and the leaves still show up as transparent.

@IdreesInc can you show a few screen shots of the issue

Sure, here is a pic of a different type of tree I imported from the Blender Greenhouse:

Can you show me what the leaf material definition looks like? Kind of looks like blend mode is set the AlphaAdditive, when perhaps just Alpha would do.

I looked at the tree in the link I had in the first post and it says that the Alpha Blend Mode is Opaque. Is that what you meant by the material definition? Sorry but I am quite new to all of this.
Also, there is no transparency in the leaves either.

Now I am having trouble importing it. It said that the assets cannot be loaded even though they loaded fine before. These trees are just full of trouble. Do you guys have any places where I can find free tree assets that work with Jmonkeyengine

EDIT Nevermind. One of the trees was able to be imported but the others weren’t. Still, any idea where to find some working assets?

Here is another picture of the transparent leaves with a different model. Maybe it has something to do with sapling generation

Ok, even though I did not find an answer to how to fix the transparent leaves, I did find a very useful plugin. It is caled Forest Generator and it creates trees in the IDE itself. It is fast and much easier than using a 3d modeling program. Here is the link: http://hub.jmonkeyengine.org/forum/topic/tree-generator/

@IdreesInc this is a problem with the generated material from your blender setup. I will post a material when I get home, which should work as intended.
Not sure how to setup this in blender though, perhaps @kaelthas has an idea.

Well i use a vegetation set from dexsoft. However they have when used directly similar problems.
This is why i wrote myself a small modelcompiler, that loads them, applies fixes for texturees convertes the formats ect.
As more often than not the blender files have incomplete materials, (eg missing normal maps even tho they are in the download included ect)

I suggest to go with the jmesdk and then after importing changing their material untill it fits.

There probably is something wrong with the way blender importer uses alpha type textures.
I have already seen the problem and will try to figure out what is wrong.

1 Like

@Kaelthas for this kind of things you have to use the alphaDiscardThreshold of the leaf’s material…not sure how it can be translated from bender material though.

I’m not sure that this exist in blender at all, since a raytracer can work fine without.

Basically the problem described here has little to do with alpha threshold, at least from my point of view. It is the semi transparen leaves.

If you have a model textured with an image containing alpha values, the exporter creates an additional alpha map, which will let you leaves for example shine through.

What the exporter creates is this:
[java]
Material MyMaterial : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
DiffuseMap : q1tree_tan/q1tree_tan-t7_c_tga1-DiffuseMap.png
AlphaMap : q1tree_tan/q1tree_tan-t7_c_tga1-AlphaMap.png
Minnaert : false
Specular : 0.0 0.0 0.0 0.0
Diffuse : 1.0 1.0 1.0 1.0
UseMaterialColors : true
ParallaxHeight : 0.05
Ambient : 0.0 0.0 0.0 0.0
Shininess : 20.0
WardIso : false
}
AdditionalRenderState {
FaceCull Back
Wireframe Off
DepthWrite On
PolyOffset 0.0 0.0
AlphaTestFalloff 0.0
Blend Alpha
PointSprite Off
ColorWrite On
DepthTest On
}
}[/java]

But it should be more like this:
[java]
Material MyMaterial : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
DiffuseMap : Flip t7_c.tga
Minnaert : false
Specular : 0.0 0.0 0.0 0.0
Diffuse : 1.0 1.0 1.0 1.0
UseMaterialColors : true
ParallaxHeight : 0.05
Ambient : 0.0 0.0 0.0 0.0
Shininess : 1.0
WardIso : false
UseAlpha : true
AlphaDiscardThreshold : 0.2
}
AdditionalRenderState {
FaceCull Off
Wireframe Off
DepthWrite On
PolyOffset 0.0 0.0
AlphaTestFalloff 0.0
Blend Alpha
PointSprite Off
ColorWrite On
DepthTest On
}
}
[/java]
Basically just the diffuse map, which already has alpha. Not sure about the UseAlpha flag, it showed no difference. And a AlphaDiscardThreshold would be good too (but this I would not expect from an exporter).