Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Tilemap implementation is laggy #2
Comments
|
It's laggy, but it works, even at 50-40 fps on my pc with hardware acceleration. |
|
The implementation lags a lot event at small maps, but it works. |
|
Look at that Bitmap.prototype.blt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) {
dw = dw || sw;
dh = dh || sh;
if (sx >= 0 && sy >= 0 && sw > 0 && sh > 0 && dw > 0 && dh > 0 &&
sx + sw <= source.width && sy + sh <= source.height) {
this._context.globalCompositeOperation = 'source-over';
this._context.drawImage(source._canvas, sx, sy, sw, sh, dx, dy, dw, dh);
this._setDirty();
}
};aaaand lets change source._canvas to source._image || source._canvas: Bitmap.prototype.blt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) {
dw = dw || sw;
dh = dh || sh;
if (sx >= 0 && sy >= 0 && sw > 0 && sh > 0 && dw > 0 && dh > 0 &&
sx + sw <= source.width && sy + sh <= source.height) {
this._context.globalCompositeOperation = 'source-over';
this._context.drawImage(source._image || source._canvas, sx, sy, sw, sh, dx, dy, dw, dh);
this._setDirty();
}
};Chrome v46: 5-10x performance boost in Tilemap._drawAutoTile. |
|
Ok, in this test its only 2.5x in chrome: http://jsperf.com/tilemap-optimization . I saw 5x-10x in chrome profiler. |
|
The next step is migrate to pixi.js tilemap. |
|
Ok, now I see that rpgmaker uses very specific tilemaps, which are more close to gameofbombs.com model than tiled. Im going to port my implementation :) |
|
The problem may be that if you edit the bitmap after loading (almost nobody does that anyway) The blt won't reflect changes if I'm not mistaken. |
|
Yep. I used that approach too, I changed some canvases just after loading the image. Now I use pre-generated stuff :) |
|
I looked at other performance problems, and I dont like it at all. They actually do things like "traits.filter(...).filter(...)" directly in the rendering loop, its awful :( |
|
Ok, it is fixed. We have "ShaderTilemap" plugin. For performance reasons I use vanilla implementation for canvas fallback. |
Tilemaps just plain don't work at the moment