newobject Posted July 14, 2016 Share Posted July 14, 2016 Hi! Shader newbie. I have a need to interpolate between DST and SRC colors while rendering a sprite. I kind of assumed this would be easy since some blend funcs involve DST_COLOR, but when I got into it, seems there is no way to read DST inside a fragment shader. 1) Is this true? 2) If this is true, then it seems like my only recourse is to capture my target into a texture and lerp between the sprite's texture and that captured texture. Is that right? If (2) is the only way forward, it seems that Pixi v3 lacks multitexturing support. v4 seems to have it in some capacity, but maybe not in the sense that I can assign two textures to a sprite? Is there any way to do this in Pixi v3 OR v4? Thanks! Brian Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 14, 2016 Share Posted July 14, 2016 1. Yes 2. Its possible. There is https://github.com/pixijs/pixi-picture that uses that technique to emulate OVERLAY and HARDLIGHT blendmodes. Works with v4. Please biuld v4 from sources https://github.com/pixijs/pixi.js/tree/dev/ or take it from my dropbox: https://dl.dropboxusercontent.com/u/46636530/pixijs/pixi.js Please note that its better to al the stage into a filter, that way we'll work only on GPU side and wont use "readPixels" which is REALLY SLOW. var screenRect = new PIXI.Rectangle(0, 0, renderer.width / renderer.resolution, renderer.height / renderer.resolution); stage.filterArea = screenRect; stage.filters = [new PIXI.filters.VoidFilter()]; Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 14, 2016 Share Posted July 14, 2016 BTW, which mode do you want to implement? there are many blendmodes 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.