Pixi.JS vs my own code

The place to ask questions about 3DStudio Max, Blender, Pro Motion, open source items, libraries, ect..

Pixi.JS vs my own code

Postby a_bertrand » Wed Nov 02, 2016 10:39 am

For those not knowing it Pixi.JS is a really nice 2D library which uses WebGL for speeding up the rendering:

http://www.pixijs.com/

The demos are quite impressive and it offers really nice to have possibilities, like special effects, resize, rotation and more.

However, after checking carefully and doing some tests, I ended up with the following:
A simple test with Pixi:
https://www.dotworldmaker.com/pixi/

And now a test with my full engine (press the right key to scroll):
https://www.dotworldmaker.com/play.html ... ySpeedTest

With Pixi I get around 45 FPS and with my engine 60 FPS.

You may think that my code do less than Pixi... well yes and no, my code do render at each frame, even for the same image and it has to deal with the whole game engine, so it should be actually slower. Doesn't seems the case.

What do I do with Pixi? I have a single "container" which contains all the tile sprites, then change the position of the container. When the container is <= -32 I move all the items within the container, remove those which are out, and create new one. That would make more less how it would work with a map scrolling. I would need to add yet a lot more functions to replicate the full engine, however it should be mostly ok for the test.

I don't say I'm an expert of Pixi but it seems to me that I cannot switch to it for my purpose. It has it's pro to not switch => I have full control of how things are going, and I don't need to change my render function. However it seems I don't have so much room for improvements, where I was hoping to speed up a lot the rendering. Too bad ;)

Any experience with Pixi?
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
a_bertrand
New Worlds Engine creator
 
Posts: 1507
Joined: Mon Feb 25, 2013 8:46 am
Has thanked: 15 times
Been thanked: 23 times

Re: Pixi.JS vs my own code

Postby hallsofvallhalla » Wed Nov 02, 2016 6:20 pm

Yeah thats pretty amazing, I get 7.4fps with Pixe and about 50 with yours. Very nice man!
User avatar
hallsofvallhalla
Site Admin
 
Posts: 11842
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 146 times
Blog: View Blog (3)

Re: Pixi.JS vs my own code

Postby Jackolantern » Wed Nov 02, 2016 7:45 pm

I am actually getting 60 FPS with Pixi and ~50 FPS with yours. I was doing some things in the background so I can't guarantee that is 100% accurate. But I think I could probably say they are about dead even for me.
The indelible lord of tl;dr
User avatar
Jackolantern
 
Posts: 10802
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 85 times
Blog: View Blog (1)

Re: Pixi.JS vs my own code

Postby a_bertrand » Wed Nov 02, 2016 11:26 pm

Thanks for the tests. As said I was expecting much better results for pixi.js than I actually get, but hey, that's not all bad I can concentrate myself on other areas instead of replacing my render engine.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
a_bertrand
New Worlds Engine creator
 
Posts: 1507
Joined: Mon Feb 25, 2013 8:46 am
Has thanked: 15 times
Been thanked: 23 times

Re: Pixi.JS vs my own code

Postby Jackolantern » Fri Nov 04, 2016 7:34 pm

The benefits of Pixi aren't just in performance. It has nice WebGL shader effects built-in, and those are a pain to create yourself unless you are familiar with HLSL. It has a bundle of other effects and features of course. Another awesome feature it has is that everything is implemented in both WebGL and Canvas. It will favor WebGL and fall back to Canvas if it needs to. If I had to go with a major off-the-shelf implementation versus rolling my own, I would go with the existing solution just so I don't have to create those features myself as my project grows. Even if you don't need tinting, WebGL shaders or other advanced features, it would be nice to know they are there if you need them in the future. And a canvas fallback out-of-the-box is pretty great.
The indelible lord of tl;dr
User avatar
Jackolantern
 
Posts: 10802
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 85 times
Blog: View Blog (1)

Re: Pixi.JS vs my own code

Postby a_bertrand » Fri Nov 04, 2016 8:44 pm

I would tend to agree, but from the tests the performances are simply not acceptable. For example on the laptop of the artist pixi drops at 6FPS vs 60FPS for my code. I would say it depends heavily on the graphic card and of course laptops tends to have very weak solutions.

Without talking about the time needed to change the code, I simply would have an hard time justifying switching over currently. For a new project then maybe it make sense, but again it is really important to check out the performances before going too far.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
a_bertrand
New Worlds Engine creator
 
Posts: 1507
Joined: Mon Feb 25, 2013 8:46 am
Has thanked: 15 times
Been thanked: 23 times

Re: Pixi.JS vs my own code

Postby Jackolantern » Fri Nov 04, 2016 8:57 pm

Out of curiosity, is it running in WebGL or Canvas mode when it drops to 6 FPS? Is your renderer using WebGL or Canvas?
The indelible lord of tl;dr
User avatar
Jackolantern
 
Posts: 10802
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 85 times
Blog: View Blog (1)

Re: Pixi.JS vs my own code

Postby a_bertrand » Fri Nov 04, 2016 10:16 pm

pixi was running WebGL when dropping to 6FPS, mine is running only canvas.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
a_bertrand
New Worlds Engine creator
 
Posts: 1507
Joined: Mon Feb 25, 2013 8:46 am
Has thanked: 15 times
Been thanked: 23 times

Re: Pixi.JS vs my own code

Postby Jackolantern » Sat Nov 05, 2016 12:52 pm

That is really, really strange. WebGL should almost always have at least equal performance to canvas, if not better. But, there are still some poor implementations out there of WebGL, though.

That is really a red flag for me, personally, though. Pixi chose WebGL as the renderer even when WebGL is running horribly. Since Pixi powers Phaser and Lazer, that could affect a lot of games.
The indelible lord of tl;dr
User avatar
Jackolantern
 
Posts: 10802
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 22 times
Been thanked: 85 times
Blog: View Blog (1)

Re: Pixi.JS vs my own code

Postby a_bertrand » Sat Nov 05, 2016 2:13 pm

Yes it could, but usually people use it with relatively a low number of sprites, where I had to have a sprite per tile which quickly end up with an high number.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
a_bertrand
New Worlds Engine creator
 
Posts: 1507
Joined: Mon Feb 25, 2013 8:46 am
Has thanked: 15 times
Been thanked: 23 times

Next

Return to Programs/Assets/Libs/Open Source/Ect...

Who is online

Users browsing this forum: No registered users and 1 guest

x