Strange things happening in space!

Hi everyone,

I have an enemy ship that have transparency activated like this:

 
        # new render bins 
        CBM=CullBinManager.getGlobalPtr() 
        CBM.addBin('textCursorBin',CullBinEnums.BTUnsorted,500) 

        # I have to split it into an isolated render bin 
        # to avoid the blink bleeding to the text 
        self.boss1.setBin('textCursorBin',0)
        
        self.boss1.reparentTo(self.basenode)
        self.boss1.setTransparency(TransparencyAttrib.MAlpha)
        self.boss1.setScale(0.002, 0.002, 0.005)
        self.boss1.setHpr(-180, 0, 0)

The enemy ship become invisible only when hit, but that’s not the case right now.

I have my plasma shot that do not have transparency activated but have transparency on it (it’s a png).

Here is what happend: What is transparent around the plasma shot makes the enemy ship transparent!!

What can I do to correct this? If you need more information, let me know!

Thanks!

Jaff

Short answer:
use MDual or something else instead of MAlpha.
Long answer:
panda3d.org/manual/index.php/Trans … d_Blending
Scroll down to the long section at the bottom.

You might try setting the Depth Test render attribute on the plasma shot. I’d try MAlways first but I’m not sure on that.

Eum… I tried your things but nothing works…

What I did not tell you is that my plasma shot is an animation… I would like to create an alpha map separatly (like it’s said in the text) but I can’t do this for like 100 png…

Here is the code… maybe it can help you helping me find a solution? :S

#Load the model for plasma weapon
        self.mainBeam = loader.loadModel("models/Plasma/plasma.egg") 
        self.mainBeam.setScale(6,6,6) 
        self.mainBeam.setBillboardPointEye() 
        self.mainBeam.setLightOff()
        self.mainBeam.show()
        self.mainBeam.setPos(self.pos)
        self.mainBeam.setX(self.mainBeam.getX())
        self.mNode = self.mainBeam.find('**/+SequenceNode') 
        self.mNode.node().stop() 
        self.mNode.node().pose(0) 
        self.mainBeam.reparentTo(self.root_plasma)
        self.mNode.node().play()
        
        #I try this with no results
        #self.mNode.setDepthTest(True)
        #self.mNode.setAttrib(DepthTestAttrib.make(RenderAttrib.MAlways))
        
        #I try this with no results too
        #self.mainBeam.setDepthTest(True)
        #self.mainBeam.setAttrib(DepthTestAttrib.make(RenderAttrib.MAlways))

In the worst case I will just remove the transparency from my enemy and make him realy easy to kill :frowning:

Thanks

Jaff

It’s because you’re using a higher order render bin for the ship. In my case (2d), I only need to isolate the text cursor, which is always on top of the text, so it’s OK using isolated render bin. But for 3d world, you’d better live without it, unless you know that an object is and will always be on top/bottom of anything else. For a ship, if it’s behind a planet, it will keep rendered on top of the planet.
Still, it’s hard to duplicate ship-cloud blink bleed as yours.

I find that for rendering glowing particle effects, the best solution is to use additive blending, depth test enabled, depth write disabled, rendered last:

nodePath.setAttrib(ColorBlendAttrib.make(ColorBlendAttrib.MAdd))
nodePath.setDepthTest(1)
nodePath.setDepthWrite(0)
nodePath.setBin(‘glowingStuffBin’, 0)

Where glowingStuffBin is after the bin you use for regular transparent rendering. So let me explain what this does. Panda’s transparency attrib turns on alpha-blending. Alpha blending blends the polygon into the framebuffer using this formula:

result = polygon_color * alpha + framebuffer_color * (1-alpha)

Instead, my code uses additive blending:

result = polygon_color + framebuffer_color

In other words, the polygon just makes the framebuffer brighter, never darker. This is absolutely perfect for bright glowing particles. Better yet, addition is commutative, so it doesn’t matter what order the glowing particles are rendered: you don’t have to depth-sort them relative to each other.

Finally: turning off depth-write ensures that a semi-transparent particle doesn’t hide the other semi-transparent particles behind it.