Barduck Posted August 26, 2020 Share Posted August 26, 2020 Hi, I don't like to bother, but I don't sure what I'm doing and I need some guidance if it's possible... I have two containers, one for map sprites (320x180px) and the other for UI graphics (who it's resized to native resolution, in my case 1920x1080) My intention is to rescale map_sprites_containter and all its sprites to 1920x1080 in the most efficient way, every frame. So I came up with the idea of render a texture of map_sprites_container, convert it to a sprite and scale it. Is this the best way? Some pseudo code: var bitmap = new Bitmap(320, 180); var renderTexture = PIXI.RenderTexture.create(320, 180); renderer.render(map_sprites_containter, renderTexture); var canvas = renderer.extract.canvas(renderTexture); bitmap.context.drawImage(canvas, 0, 0); canvas.width = 0; canvas.height = 0; renderTexture.destroy({ destroyBase: true }); bitmap.baseTexture.update(); var render_map_sprites = new Sprite(); render_map_sprites.bitmap = bitmap; render_map_sprites.scale.x = 6 render_map_sprites.scale.y = 6 map_sprites_containter.addChild(render_map_sprites); Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 26, 2020 Share Posted August 26, 2020 and how does it look? like 320x180px scaled to 1920x1080 with LINEAR? Quote Link to comment Share on other sites More sharing options...
Barduck Posted August 26, 2020 Author Share Posted August 26, 2020 I use NEAREST because it's pixel art. I'm at work in this moment so I can't show you but looks okay. Do you think that this way of doing it can have big impact on performance? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 26, 2020 Share Posted August 26, 2020 (edited) I honestly dont know why do you need "extract" and "destory" here. just re-use the same renderTexture every time it changes. It can give you extra perf if your UI is flilrate-heavy, like, filling the same area 10 times. Edited August 26, 2020 by ivan.popelyshev Barduck 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 26, 2020 Share Posted August 26, 2020 extract uses readPixels which is slow. I dont understand whats your "bitmap", is it RMMZ thing? If its RMMZ, find a way to swap texture inside bitmap to RenderTexture. Barduck 1 Quote Link to comment Share on other sites More sharing options...
Barduck Posted August 26, 2020 Author Share Posted August 26, 2020 Oh I see, thank you Ivan! Yes I'm experimenting with RMMZ framework, nothing serious mostly for learning. So I'm in the right way, I need to adjust that things you pointed me. Thank you again ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.