Flint Particle System Forum - Alpha doesn't appear to work with PixelRenderer2013-09-01T10:35:12+01:00http://flintparticles.org/forum/
Lussumo Vanilla & Feed Publisher
Alpha doesn't appear to work with PixelRendererhttp://flintparticles.org/forum/comments.php?DiscussionID=587&Focus=1999#Comment_19992013-01-20T16:47:49+00:002013-01-20T16:49:41+00:00TomAugerhttp://flintparticles.org/forum/account.php?u=650
Using a PixelRenderer, it seems that alpha (such as set in a ColorInitializer, or in a Fade action) doesn't actually work, at least not the way I would expect.
If each new particle has an alpha ...
If each new particle has an alpha setting, one would expect that if we set clearBetweenFrames to false, particles that end up being drawn over a pixel that has already had a particle on it should add their colour to the existing colour of the pixel. That does not occur.
In the example below, the center of the DiscZone should get progressively darker and darker as particles are drawn over top of pixels that have already had particles traverse them. Instead, the center of the zone mysteriously gets lighter! Almost as if the alpha is the alpha of the pixel (ie: on the Renderer), rather than the alpha of the particle.
Please note: the examples below assume a white or light stage colour.
renderer = new PixelRenderer( new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight ) ); renderer.clearBetweenFrames = false; emitter = new Emitter2D();
emitter.counter = new Steady( 500 );
emitter.addInitializer( new ColorInit( 0xff000000, 0xff000000 ) ); emitter.addInitializer( new Position( new DiscZone( new Point( stage.stageWidth/2, stage.stageHeight/2 ), 50, 0 ) ) ); emitter.addInitializer( new Lifetime( 5, 10 ) ); emitter.addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 2, 1 ) ) );
emitter.addAction( new Move() ); emitter.addAction( new Fade() ); emitter.addAction( new Age() );
In fact, for an even more obvious case: remove the Fade action, and add a ColorInitializer with alpha, like this: emitter.addInitializer( new ColorInit( 0x20000000, 0x20000000 ) );]]>
Alpha doesn't appear to work with PixelRendererhttp://flintparticles.org/forum/comments.php?DiscussionID=587&Focus=2000#Comment_20002013-01-22T02:55:20+00:002013-09-01T10:35:12+01:00TomAugerhttp://flintparticles.org/forum/account.php?u=650
I'm no longer 100% convinced that this is a bug, but rather an idiosyncrasy of the PixelRenderer. Still, I wonder whether it couldn't be improved. I'm noticing that you're using SetPixel32 to simply ...
In my specific use case, I am more looking to draw on a flattened "canvas", so the following class addresses that need by providing an opaque BitmapData object that is filled with an opaque colour (white in this case). Then, the drawParticle method uses the alpha value of the particle as a blend value against the pixel colour that's already there.
/** * ... * @author Tom Auger */ public class OpaqueAlphaRenderer extends PixelRenderer { public function OpaqueAlphaRenderer(canvas:Rectangle) { super(canvas);
}]]>
Alpha doesn't appear to work with PixelRendererhttp://flintparticles.org/forum/comments.php?DiscussionID=587&Focus=2001#Comment_20012013-01-22T02:56:01+00:002013-09-01T10:35:12+01:00TomAugerhttp://flintparticles.org/forum/account.php?u=650
If anyone knows a faster way to combine the colours without first bitwise splitting them up, please post it!