colourclash Posted January 29, 2016 Share Posted January 29, 2016 Has anyone also noticed that the Screen blend mode while using the WebGL renderer looks more like an additive blend? I've attached a test image to demonstrate the problem. What I've done to fix it in the meantime (which to be honest is a blind guess) is to change this line in WebGLRenderer.jsthis.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; to thisthis.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.ONE, gl.ONE_MINUS_SRC_COLOR]; Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 29, 2016 Share Posted January 29, 2016 And another moment of fame for me! There're pull requests about it: https://github.com/pixijs/pixi.js/pull/2321 . It switched gl.SRC_ALPHA to gl.ONE if texture has premultiplied alpha. And second parameter is gl.ONE_MINUS_SRC_COLOR and I think it is correct. Build is here: https://dl.dropboxusercontent.com/u/46636530/pixijs/blendMode/pixi.js Test it please, I need a feedback. Quote Link to comment Share on other sites More sharing options...
colourclash Posted January 29, 2016 Author Share Posted January 29, 2016 Hi Ivan, Testing with your build, the screen blend now looks identical to the photoshop version Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 29, 2016 Share Posted January 29, 2016 Can you please add "texture.baseTexture.premultipliedAlpha=false" in your demo, before you render it? We need to test that too. Quote Link to comment Share on other sites More sharing options...
colourclash Posted January 29, 2016 Author Share Posted January 29, 2016 okay.. it looks slightly lighter now. I'm just using a standard .png output from photoshop which I guess is not pre-multiplied? EDIT: actually it looks identical to the previous output! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 29, 2016 Share Posted January 29, 2016 It looks the same. Actually, it cant be different , because your texture has no alpha component at all. The only major thing we changed is the second parameter, and now its corrected. Quote Link to comment Share on other sites More sharing options...
colourclash Posted January 29, 2016 Author Share Posted January 29, 2016 So, testing with an image containing alpha I get: tex.baseTexture.premultipliedAlpha = false; Quote Link to comment Share on other sites More sharing options...
colourclash Posted January 29, 2016 Author Share Posted January 29, 2016 tex.baseTexture.premultipliedAlpha = true; Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 29, 2016 Share Posted January 29, 2016 And which one is correct? Can you plese change "PIXI.autodetectRendere" to "new PIXI.CanvasRenderer" ? Quote Link to comment Share on other sites More sharing options...
colourclash Posted January 29, 2016 Author Share Posted January 29, 2016 For my purposes the second output above is what I need. I did some tests with a non-premultiplied image and setting baseTexture.premultipliedAlpha to false which to my eyes didn't look the way I would expect - I normally just go with pre-multiplied images so perhaps someone who is using non-premultiplied textures can chime in here. When switching to canvas renderer, with baseTexture.premultipliedAlpha set to true or false, they both look like the second image above. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 29, 2016 Share Posted January 29, 2016 That's very strange. I'd like to debug the variant with premultipliedAlpha=false; , can you please upload it to codepen.io? I can do that too, but just to save time.. 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.