Sign in to follow this  
Iavra

Converting a filter to PIXI v4

Recommended Posts

It seems i get a weird bug. Here's my test layer, that gets added to the scene (initialize gets called once, update gets called each update):

$.LIGHTING.Layer.prototype = $._extend(Object.create(PIXI.Container.prototype), {

    initialize: function() {
        PIXI.Container.call(this);

        //this.addChild(this._demo = PIXI.Sprite.fromImage('img/occlusion.png'));
        this._occlusion = PIXI.Sprite.fromImage('img/occlusion.png');

        this._test = new PIXI.Sprite(PIXI.RenderTexture.create(500, 500));
        this.addChild(this._test);
        this._test.filters = [new $.LIGHTING.RectangularToPolarFilter(), new $.LIGHTING.PolarToRectangularFilter()];

        Window.x = 0;
    },

    update: function() {
        this._occlusion.x = Window.x;
        Graphics._renderer.render(this._occlusion, this._test.texture, true);
    }

});

Now, it seems to work fine, as long as i don't move around the occlusion map. As soon as i do so, the filtered image updates, but it seems like older data (which should have been cleared from the RenderTexture) is still there (images are with Window.x = 0, 100 and 0 again):

1.jpg2.jpg3.jpg

I expected it to work, because when i render the occlusion map to the render texture, the filters aren't involved at all (or so i thought). If i don't use the filters, the texture gets updated correctly.

This is the occlusion map i'm using:

occlusion.png

Share this post


Link to post
Share on other sites

It's actually an Rpgmaker plugin (though i'm using the latest PIXI version instead of the bundled one). The whole plugin can be found here: http://pastebin.com/qrFV6ThW

It shouldn't be that hard to translate to a non-RM environment, though. Basically, you add an instance of IAVRA.LIGHTING.Layer to a scene and call its "update" function on each frame. "Graphics._renderer" would need to be substituted with however the PIXI.WebGLRenderer instance is called. Aside from that, i'm not using any RM specific classes.

/edit: For now i'm working on per-vertex lighting, instead (example: http://ncase.me/sight-and-light/), since it's easier to grasp, until i come up with a solution ^^

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.