Migi Posted January 25, 2016 Share Posted January 25, 2016 Hello, Is it possible to achieve the same effect in Pixi.js as what BlendMode.LAYER does in Flash? Here's a good demonstration of what BlendMode.LAYER does: http://www.zedia.net/2008/blendmodelayer-a-must-when-changing-alpha-of-a-displayobject-containing-other-displayobject/ Drawing transparent objects (like enemies) consisting of multiple components (arms, hands, weapon, etc) looks horrible without this effect. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 25, 2016 Share Posted January 25, 2016 You can do that by adding any filter or mask to the object, it will be rendered to separate RenderTexture which will be drawn on screen. Quote Link to comment Share on other sites More sharing options...
Migi Posted January 25, 2016 Author Share Posted January 25, 2016 This is not working for me. If I go to the masking example on pixijs.com and add "container.alpha = 0.5;", the bgFront, light1 and light2 sprites are clearly visible behind the panda sprite. This is true for both the canvas and webgl renderers, but wouldn't be the case with AS3's BlendMode.LAYER, because the panda sprite would be drawn on top of the bgFront, light1 and light2 sprites at full opacity, completely obscuring those sprites, and then the whole container would get alpha 0.5. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 26, 2016 Share Posted January 26, 2016 What about filter? create PIXI.AbstractFilter with no params and add it to your container. Quote Link to comment Share on other sites More sharing options...
Migi Posted February 3, 2016 Author Share Posted February 3, 2016 No, adding a PIXI.AbstractFilter didn't change anything. I'm probably just doing it wrong. Could someone share a very simple code example drawing 2 circles at alpha 0.5 where the intersection doesn't have a different color than the rest of the circles? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 3, 2016 Share Posted February 3, 2016 Oh, now i understand what are you trying to do. There are problems with both alpha and blendmodes, I dont know a way of doing that easy case in pixi, except may be adding this circles into some container that will be cached with "cacheAsBitmap=true" and than making alpha=0.5 for it or its parent. Quote Link to comment Share on other sites More sharing options...
Migi Posted February 4, 2016 Author Share Posted February 4, 2016 Yes, thank you. CacheAsBitmap=true works and achieves the desired effect. Coming from AS3/Flash, I was pretty surprised by this because in Flash cacheAsBitmap has no effect on how an object looks, it only affects the performance of the rendering. But here in Pixi, that's evidently not the case, not only because cacheAsBitmap changes the outcome when 0 < alpha < 1, but it also makes it stop updating when the children update. I'd go so far as to call this a bug, or at least a serious misuse of the term "caching". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.