This is a game i’m making (assets are “borrowed” from blizzard, I’m going to write an article on that later)
However i’m not satisfied with how the alpha blending is done.
But i’m fairly sure that it’s just a matter of one simple configuration option that I don’t know about
This is an example texture I work with:
They are all in PNG format and have a transparent background.
The alpha works in panda, partially, but it seems to “blend” with grey for some reason. You can see it in the leaves of the trees in the screenshot.
Weird thing is… I render them as two sided polygons and it seems that the other side is fine… sometimes. It also depends on the angle I view them from, from some angles the transparency is correct.
Allthough when i say correct, I mean that I don’t get grey. But instead something like this: (see lower one)
But i suspect that has to do with the ordering of polygons… Which i’m not sure I can do anything about because I get it as 1 model.
Anyway… any help would be appriciated!
Yes, this is a polygon ordering issues. Since the tree is one model and is self-occluding, Panda is unable to sort the polygons automatically in the correct back-to-front order for soft-edged transparency. This means that the antialiased edges of your cutouts look weird when they happen to get sorted incorrectly (and whether they get sorted correctly depends on the viewing angle).
This is a problem with any 3-D engine, not just Panda. There are several possible solutions, but none of them is perfect. See the Transparency and Blending page for a longer explanation, not all of which pertains to this situation.
The easiest thing to do in your case is probably to use MBinary or MMultisample mode to enable transparency, instead of the default MAlpha:
You might also try MDual, but from the screenshots I think you might already be using that mode.
You can also enable this mode by editing the egg file, or by setting a flag in egg-palettize if you are using that tool.
The edges of his leaves look like his sky dome. Here’s what I think is happening:
Panda renders the sky, filling the screen with greenish grey.
Panda renders some leaves. The edges of the leaves are 80% transparent, and they blend with the grey-green sky, leaving mostly grey-green. These blended pixels are written to the frame buffer with depth-writes enabled.
Panda tries to render some more leaves behind those leaves, but because depth-writes were enabled, those leaves are occluded by the grey-green edge pixels that were written before.
This is the exact situation that MDual was designed for… he should try MDual.
I had actually tried setting render to MDual with no luck, but setting it directly on the node, with priority, fixed my problem!