Jump to content

How to increase brightness of a Sprite?

Julio Rodrigues

Recommended Posts

Well, I have no context here, about where you're gonna use this, but I'm assuming this won't be fast, and could not be used in an update loop, as in applying continuously the brightness.


So first one, tint

spriteInstance.tint = 0xFF0000; // tint the sprite with RED

Second, you could use this method here: http://www.html5gamedevs.com/topic/4139-get-access-to-pixel-color-from-a-texture/

Note: Keep in mind this is actually generating a new texture, which in webGL means uploading it back to the engine. This could take a while, depending on the texture size, environment, etc.



Link to comment
Share on other sites

  • 6 years later...
function brightnessFilter(b){ // -1~1
            let filter = new PIXI.filters.ColorMatrixFilter();
                if(b >0){
                    filter.matrix = [
                        1-b, 0, 0, 0, b,
                        0, 1-b, 0, 0, b,
                        0, 0, 1-b, 0, b,
                        0, 0, 0, 1, 0];
                    filter.matrix = [
                        1, 0, 0, 0, b,
                        0, 1, 0, 0, b,
                        0, 0, 1, 0, b,
                        0, 0, 0, 1, 0];
    return filter;
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...