I created 2 leafs of a tree by mapping a transparent texture to a plane.
and the code is below.
self.tree = loader.loadModel(MYDIR+"/models/world/tree")
self.ty = TextureStage('ty')
pattern1 = loader.loadTexture(MYDIR+"/models/world/fabric.png")
self.ty.setColor(Vec4(1, 0, 0, 1))
self.tree.setTexScale(self.ty, 1, 1)
But when I moved the camera looking for a sight where the 2 leafs
are overlaping. I will see a little transparent border encapsulate the front
leaf. (Looks like a picture below.)
How can I erase that border?
The basic MAlpha transparency mode does not fix this borders. You would have to use MDual or MBinary or MMultisample. (or something similar)
In the second part of this page you can read which transparency mode to choose.
The particular case you’re trying to do, palm leaves, is a difficult one. I wrote a game set in a tropical environment and I had the same problem. Depth sorting just isn’t practical here. You can use alpha-testing, but that tends to create some jaggies.
I came up with a method that gives pretty good results. It requires two-pass rendering. First, render the model with alpha testing and a very strict alpha-test (alpha == 1.0). That renders everything but the edges of the leaves. Then, in a second pass, render the edges of the leaves using a loose alpha-test (alpha > 0.1), alpha blending, and no write to the z-buffer.
This method gives very good results.
PS. It occurs to me that you could speed up the first pass a bit by turning off color writes entirely - just render to the Z-buffer.
Note that this two-pass algorithm is so generally useful, it’s been hardcoded into Panda as transparency mode MDual.
Thanks a lot everyone!!
I will try…