Jump to content

Clear Rect in Render Texture


Hebbe
 Share

Recommended Posts

Hi!

I'm using pixi 4.5.3 and can't find a way to clear out an rectangle from my transparent render texture. Seems that all blend modes have gl.ONE_MINUS_SRC_ALPHA in them :(

Is there any hack around this?

I have a large renderTexture with mostly static bitmap text and I want to update only parts that have changed for better performance. Is there any other way to update only part of an rendertexture while retaining transparency?

Thanks!

 

Link to comment
Share on other sites

There's a branch for that case, make your own blendMode: https://github.com/pixijs/pixi.js/pull/4049 , the build is here: https://pixijs.download/dev-blendmodes-class/pixi.js

var gl = app.renderer.gl; //the context
var mySuperBlendMode = new PIXI.BlendMode(gl.ONE, gl.ONE); //its actually kinda ADD ;)

sprite.blendMode = mySuperBlendMode;

Unfortunately its too heavy change for pixi-v4 , so it will be introduced in v5. For now you can just use the branch, its up-to-date :)

UPD. Do remember that both canvas and texture are premultiplied by default, that means (R*a, G*a, B*a, a) are stored instead (R,G,B,a). All coefficients are applied to those numbers.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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