rainerpl Posted May 4, 2019 Share Posted May 4, 2019 Hi, Im trying to make a simple app/feature, that fills an area with random pixels(random color at random time) I have a working solution that is only a handful of lines of code, but its crazy slow. (uses WegGL and Nvidia GTX1060 gfx card + i7 cpu ). The way i fill the canvas with random pixels at the moment is like this: 1) set interval that calls the drawRandomPixels function( it struggles to draw 1 frame every 250 ms ) 2) loop over every pixel coordinate(x, y) and use this.contentGfx.fillColor = 0xFFFFFF * Math.random(); this.contentGfx.drawRect(x, y, 2, 2); 3) after all the pixels have been looped over, call the endFill() and render the stage. Very simple and basic, yet it has massively worse FPS than what i get when i play Battlefield 5 on highest settings. The area that im trying to fill is 250 x 250 canvas. I used 2x2 pixel size to get a bit better performance but its still damn awful. Is there a better way to draw pixels in PIXI ? ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 4, 2019 Share Posted May 4, 2019 if its v5 just put random stuff in BufferResource. https://pixijs.io/examples/#/textures/gradient-resource.js - that demo uses custom TextureResource, but you can just use BufferResource: http://pixijs.download/dev/docs/PIXI.resources.BufferResource.html Report if something goes wrong. Quote Link to comment Share on other sites More sharing options...
rainerpl Posted May 5, 2019 Author Share Posted May 5, 2019 Thanks for the reply, Im not using v5, and upgrading is not an option for now. Any way to use the previous pixi version to do simple pixel level operations at reasonable FPS? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 5, 2019 Share Posted May 5, 2019 OK, make a canvas2d, make a texture out of it, fill the canvas with pixels through https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/putImageData . Call "texture.update()" every time you change it there. 250x250 every frame should be fine 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.