jaevelgames Posted March 6, 2015 Share Posted March 6, 2015 Hi! I'm making a game where I want to add and use a bunch of singe pixels. What would be best practice for that, CPU wise? Should I let Pixi draw a 1x1 rectangle, or simply create a pixel as a .PNG and add as a sprite (even though it feels kind of silly)? Or does it really matter? I'm guessing there will be around 100 visible simultaneously.. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
msha Posted March 7, 2015 Share Posted March 7, 2015 Does not matter performance-wise... I'd do it with graphics for maintainability. Quote Link to comment Share on other sites More sharing options...
agamemnus Posted March 7, 2015 Share Posted March 7, 2015 It really depends on how many pixels you have. For this, with 100, it is probably better to use polygons (sprites) instead of pixels, since you are drawing to the texture and that requires some back and forth between the CPU and GPU. (assuming the game is supposed to run in webGL) Quote Link to comment Share on other sites More sharing options...
jaevelgames Posted March 9, 2015 Author Share Posted March 9, 2015 Thanks for the answers! Just for curiosity.. When and why would it wiser to draw the graphics instead? Like, what is the main benefit? Quote Link to comment Share on other sites More sharing options...
agamemnus Posted March 9, 2015 Share Posted March 9, 2015 So again, if you are doing stuff with pixels that is difficult or impossible with polygons (in your estimation), you should modify the texture. Otherwise, modify the sprite. It is a different architecture. With pixels, you have more control but you need to send this information (e.g.: a texture) to the GPU each frame. Thus, there can be a data bottleneck if the texture is big. With polygons and textures, most of the data is already sent to the GPU. You just have to send some positioning data, for example. That's why there are filters and shaders and such... to help with some common graphics manipulation cases. WebGL ES 2.0 is fairly limited.. WebGL 3 should make things easier, as well. jaevelgames 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.