Transparency issue

Hi everyone,

My game is ALMOST finish hehehe. But right now I have a strange bug!
When my enemy receive some hit, the enemy become invisible for a couple of time and become visible again after a while.

Here is the interval that do the job:

self.hideModelIntervalboss = LerpColorScaleInterval(self.boss1, 0.2, Vec4(0,0,0,0), Vec4(1,1,1,1))
        self.showModelIntervalboss = LerpColorScaleInterval(self.boss1, 0.2, Vec4(1,1,1,1), Vec4(0,0,0,0)) 
        self.invisibleAttack = Sequence(self.hideModelIntervalboss,
                                        Wait(0.4),
                                        self.showModelIntervalboss,
                                        name="invisible Attack")

It work perfectly! The problem is that the planet that the enemy is orbiting around that also use transparency (for the clouds) became invisible too, at the same time…

Here is the code for the planet and the clouds:

#About the planet
        #=======================================================================
        self.root_planet = self.dummyAmbiant.attachNewNode('root_planet')
        self.root_planet.setPos(0,0,0)
        
        #load the BIG planet that we are orbiting around 
        self.mainplanet = loader.loadModel("models/planet/sphere-highpoly.egg")
        self.mainplanet_tex = loader.loadTexture("models/MarsMap_2500x1250.jpg")
        self.mainplanet.setTexture(self.mainplanet_tex, 1)
        self.mainplanet.setScale(20)
        self.mainplanet.reparentTo(self.root_planet)
        self.mainplanet.setPos(0, 0, 0)
        
        #add transparency
        self.nuage = loader.loadModel("models/planet/sphere-highpoly.egg");
        self.nuage_tex = loader.loadTexture("models/EarthClouds_2500x1250.jpg")
        self.nuage.setTexture(self.nuage_tex, 1)
        self.nuage.setScale(20.1)
        self.nuage.setTransparency(TransparencyAttrib.MAlpha)
        self.nuage.setAlphaScale(0.3)
        self.nuage.reparentTo(self.root_planet)
        self.nuage.setPos(0, 0, 0)

Am I missing something? They are completly independant node so it’s impossible that my transparency transformation on the enemy can impact the planet. I don’t understand…

Thanks!

Jaff

The problem might be due to the transparency sorting it should get it right but this is worth a try. Make sure not to change the ‘bin’ of the transparent nodes and use setTransparency(TransparencyAttrib.MDual)

Your problem is just like one in my IDE, the cursor’s blink color scale bleeds to the whole text, so the whole text blinks too !! But that’s only when I have screenful duplicated text lines.
I fixed that simply by moving the cursor into an isolated render bin.

Hmm, that might be also the problem - i also have experienced texture bleeds but they are so hard to duplicate.

Thanks,

I will look for that during the weekend!

Jaff

Ok maybe it’s because of my poor knowledge of english, but what do you mean by “bin”?

Because I tried changing the Malpha for MDual and the problem is still there…

Can you explain me in more detail what you mean by the “bin”

Thanks!

Jaff

www.panda3d.org/manual/index.php/How_t … nder_Order

  Bin Name        Sort  Type
   --------------  ----  ----------------
   "background"     10   BT_fixed
   "opaque"         20   BT_state_sorted
   "transparent"    30   BT_back_to_front
   "fixed"          40   BT_fixed
   "unsorted"       50   BT_unsorted

Hi,

Thanks for the great support. I’m not sure to understand clearly the story of the bin and how I did it, but I got it fixed with this code:

#Load the boss1
        self.boss1 = loader.loadModel("models/boss1/boss1.egg")
        
        #for the transparency bug
        self.boss1.setBin("unsorted", 25)

Since I’m curious, can someone explain what I just did? :slight_smile:

Thanks!

Bins tell panda how to order stuff.

The background bin just sort relative it their order (that is what second param to set bin is)

opaque bin sorts every thing according to less state transformations, it start with one texture/shader then draws every thing with that texture/shader.

transparent bin sort every thing back to front. So that stuff at the back is drawn first then, stuff before it and before it. This way the transparent stuff covers what is in the back like glass. If you do front to back it will draw the glass before you first and the glass in the back will not get drawing at all because it would fail the depth test.

Now why did this sorting didnot work for you? My guess is that your planets’s bounding box extends behind object so it is drawn first. But the planet is so big it depth clips the object so the object fails the depth test and does not get drawn.

Now that unsorted bin tells every thing to draw just randomly it it turn out to be in the right order. I suggest using fixed bin with planet at bin 2 and object at bin 1 because then object will always be first.