Ruskibloo Posted March 8, 2023 Share Posted March 8, 2023 Hi all, I'm stumped on a filter use case that I've distilled in the following example. I have a Sprite with a CRTFilter on it. When the sprite is fully-visible in the canvas, it renders as expected, covering the entire Sprite. However, when the Sprite is moved partially off-screen, the filter is squashed to render entirely within the visible portion of the Sprite. I'm wondering if there's a way to render the filter in a way that it looks like it's following the Sprite, and clipped where necessary? Basically like this (photoshop mockup): I've tried looking at properties I can feed to the shader from overriding Filter.apply(), but there doesn't seem to be any good ones. What's the proper way to do this, if any? Thanks for any help! The code's pretty basic, but just to be thorough, here it is: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Pixi Experiment</title> <script src="https://pixijs.download/release/pixi.js"></script> <script src="https://cdn.jsdelivr.net/npm/pixi-filters@latest/dist/browser/pixi-filters.min.js"></script> </head> <body> <script> const app = new PIXI.Application({ width: 640, height: 480, backgroundColor: 0x2c3e50 }); document.body.appendChild(app.view); const cat = PIXI.Sprite.from('cat.jpg'); const crtFilter = new PIXI.filters.CRTFilter(); cat.filters = [crtFilter]; // Center the sprite's anchor point cat.anchor.set(0.5); cat.x = 0; // app.renderer.width / 2; cat.y = app.renderer.height / 2; app.stage.addChild(cat); </script> </body> </html> Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 8, 2023 Share Posted March 8, 2023 "filter.dontFit=true" Ruskibloo 1 Quote Link to comment Share on other sites More sharing options...
Ruskibloo Posted March 8, 2023 Author Share Posted March 8, 2023 Ah, looks like the updated property is filter.autoFit. Setting that to false makes it work. Thanks so much @ivan.popelyshev! 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.