Transparency problem

due to my lack of experience I’m having problem to set up my scene with transparency, in the preview in the chicken exporter for blender it shows everything okay, but when I load the models from my egg file, they are being displayed incorrect.

I tried MDual instead MAlpha but the problem persists, what do I need to know?

that’s the code I’m using: = loader.loadModel('Models/City/city')

Thank your attention.

the texture behavior is quite strange :frowning:,

the problem is that where the texture is transparent I can see the background color sometimes. I have a plant texture in front of a house, there I can see through the house the gray color of the background :open_mouth:,

but in another position this annoying behavior does not happen and the texture is displayed correctly… :confused:

This means that (a) your house also has transparency enabled on it (is it supposed to?) and that (b) your house and the plant in front of it are either in the same mesh, or they are both part of larger meshes that have similar bounding volumes.

For correct transparency, Panda has to sort all of the transparent objects in order from back to front. It does this based on the center of their bounding volumes. When two transparent objects are in the same mesh, or when the center of their bounding volumes is nearly in the same place, then this goes wrong, and you end up with artifacts such as you describe. (You appear to “see through” the house behind the flower when the flower happens to end up being drawn before the house–this happens when the flower’s center happens to be farther away than the house’s center.)

There are several solutions, no one of which is perfect in all situations. The Transparency and Blending manual page talks a little about several possibilities.

Note that in order to apply MDual, you will have to set an override, e.g.:, 1)

but it is a terrible idea to apply MDual transparency at the top node like this, because it means your entire city now has transparency enabled, instead of just the transparent parts of it. This can actually make the problem even worse. (Ideally, you have correctly modeled your city so that only the parts that actually require transparency have transparency enabled, since opaque parts do not have this sorting issue.) The best way to apply MDual transparency to the transparent parts of a model is to do so in the egg file.

Of course, it might just be a modeling fault in the first place, if you have applied a texture with an alpha channel over the entire city. This will automatically enable transparency for everything in the city, even if the alpha channel is entirely or mostly white. It’s better to use a 3-channel texture for the parts that are opaque, and a 4-channel texture only where you actually need it.


thank you very much, the solution i found for my purpose was to export three egg files: the groundPlane.egg, cityBuildings.egg and transparentThings.egg,

to the groundPlane which is only one mesh, I did .setBin(“background”, 1) and to the transparentThings which are several meshes, I applied .setTransparency(TransparencyAttrib.MDual,1) well now all the things seem to be in your right places after hours =)