[SOLVED] Sprite particles not rendered correctly

Hi folks!

I’ve got a problem with the SpriteParticleRenderer:

As you can see, the sprites are black and in some cases replace the corresponding part of the heightfields texture (The lava is another node below the ground)
Oh and the ParticlePanel-Demo shows the effect correctly!

This is the sprite for the effect:

It’s just a blurry red dot png with alpha.

I’ve tried many different settings but the sprite looks always the same :frowning:
Here is my current code für creating the effect:

...
self.harvestParticleEffect = ParticleEffect()
self.harvestParticleEffect.setLightOff()
self.harvestParticleEffect.setShaderOff()
self.harvestParticleEffect.setTransparency(TransparencyAttrib.MAlpha)
...
self.harvestParticleEffect.reset()
self.harvestParticleEffect.loadConfig("media/harvest.ptf")
self.harvestParticleEffect.start(self.np, self.model)
self.harvestParticleEffect.setPos(0, -6, 0)

My ShowBase uses setShaderAuto() and a DirectionalLight.

Any help is appreciated!

Finally, the content of “harvest.ptf”:

self.reset()
self.setPos(0.000, 0.000, 0.000)
self.setHpr(0.000, 0.000, 0.000)
self.setScale(1.000, 1.000, 1.000)
p0 = Particles.Particles('particles-1')
# Particles parameters
p0.setFactory("PointParticleFactory")
p0.setRenderer("SpriteParticleRenderer")
p0.setEmitter("DiscEmitter")
p0.setPoolSize(30)
p0.setBirthRate(0.0500)
p0.setLitterSize(1)
p0.setLitterSpread(0)
p0.setSystemLifespan(0.0000)
p0.setLocalVelocityFlag(1)
p0.setSystemGrowsOlderFlag(0)
# Factory parameters
p0.factory.setLifespanBase(0.7000)
p0.factory.setLifespanSpread(0.0000)
p0.factory.setMassBase(1.0000)
p0.factory.setMassSpread(0.0000)
p0.factory.setTerminalVelocityBase(0.0000)
p0.factory.setTerminalVelocitySpread(0.0000)
# Point factory parameters
# Renderer parameters
p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHANONE)
p0.renderer.setUserAlpha(1.00)
# Sprite parameters
p0.renderer.addTextureFromFile('media/lavaParticle.png')
p0.renderer.setColor(Vec4(1.00, 1.00, 1.00, 1.00))
p0.renderer.setXScaleFlag(0)
p0.renderer.setYScaleFlag(0)
p0.renderer.setAnimAngleFlag(0)
p0.renderer.setInitialXScale(0.0500)
p0.renderer.setFinalXScale(0.0500)
p0.renderer.setInitialYScale(0.0500)
p0.renderer.setFinalYScale(0.0500)
p0.renderer.setNonanimatedTheta(0.0000)
p0.renderer.setAlphaBlendMethod(BaseParticleRenderer.PPNOBLEND)
p0.renderer.setAlphaDisable(0)
p0.renderer.setColorBlendMode(ColorBlendAttrib.MAdd, ColorBlendAttrib.OIncomingAlpha, ColorBlendAttrib.OOneMinusIncomingAlpha)
# Emitter parameters
p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
p0.emitter.setAmplitude(-0.0100)
p0.emitter.setAmplitudeSpread(0.0000)
p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 1.0000))
p0.emitter.setExplicitLaunchVector(Vec3(0.0000, 0.0000, 0.0000))
p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, -1.0000))
# Disc parameters
p0.emitter.setRadius(2.0000)
self.addParticles(p0)
f0 = ForceGroup.ForceGroup('sink')
# Force parameters
force0 = LinearSinkForce(Point3(0.0000, -0.9000, -0.1600), LinearDistanceForce.FTONEOVERRSQUARED, 0.0140, 0.0010, 1)
force0.setVectorMasks(1, 1, 1)
force0.setActive(1)
f0.addForce(force0)
self.addForceGroup(f0)

Alpha None ?
No Blend ?

p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHANONE)
p0.renderer.setAlphaBlendMethod(BaseParticleRenderer.PPNOBLEND)

These lines are generated by the ParticlePanel. I’ve tested all 3 blendmodes (none, linear, cubic) and also removing the line, same goes for the alpha mode, but I couldn’t see any differences, until now!

I was able to remove the blackness of the sprites by adding another node as the renderParent and using this:

self.effectRenderParent.setLightOff()

(I didn’t expect the lights to have an impact on particles in panda)

Now the sprites show the right image instead of the black rectangle and when I change the blendmode and alphamode their alpha-value get rendered correctly too.

BUT, the rendering is still odd:

Have you tried putting the particle system (or associated NodePath - I forget offhand how particle systems are arranged) into a bin that’s rendered later than your ground, and turning off depth writing? My guess, looking at your screenshot, is that you’re rendering part of that terrain using multiple images, and that the particles are being rendered before at least one of said images, writing into the depth buffer and thus causing the image to not be drawn in in overlapping pixels.

(If the above is poorly-phrased, please forgive me; I’m rather tired.)

Perfect! With your suggested changes the particles get rendered correctly:

self.effectRenderParent.setDepthWrite(False)
self.effectRenderParent.setBin("fixed", 0)

Thanks ynjh_jo and Thaumaturge!