Jump to content

Blend/shader that lerps between SRC and DST?


Recommended Posts


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?




Link to comment
Share on other sites

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()];


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...