AshleyScirra2 Posted January 3, 2018 Share Posted January 3, 2018 Does Pixi.js support shaders which can sample from the background and use custom fragment shader code to blend? For example, implementing a Screen blend in a fragment shader. It's a tricky problem and I'd be interested in the implementation details if Pixi supports this, but I haven't been able to find anything on this so far. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 3, 2018 Share Posted January 3, 2018 https://github.com/pixijs/pixi-picture uses that trick to emulate OVERLAY blendmode Quote Link to comment Share on other sites More sharing options...
AshleyScirra2 Posted January 3, 2018 Author Share Posted January 3, 2018 Ah, thanks. Looks like the relevant code is in https://github.com/pixijs/pixi-picture/blob/master/src/PictureRenderer.ts. Surprised to see a readPixels in there, doesn't that kill the performance? :-S ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 3, 2018 Share Posted January 3, 2018 yeah, it kills performance, but add AlphaFilter to root (ex-VoidFilter) and it'll use texture copy instead. As a downside, say goodbye to anti-aliasing var f = new PIXI.filters.AlphaFilter(); f.filterArea = app.screen; app.stage.filters = [f]; Quote Link to comment Share on other sites More sharing options...
AshleyScirra2 Posted January 4, 2018 Author Share Posted January 4, 2018 I guess adding AlphaFilter forces the main scene to render to texture? FWIW the Construct engine automatically enables that if any background blending shaders are in use, might make sense for Pixi as well since it eliminates that slow path. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 4, 2018 Share Posted January 4, 2018 I didnt know that detail about Construct. Yep, AlphaFilter or any other filter forces usage of extra framebuffer, and its possible to copy contents from its texture to another texture and use it for blending emulation. Anyway, blending shaders are slow because of extra framebuffer and copying, dont over-use them for a few large images its fine. 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.