Snok Posted April 16, 2021 Share Posted April 16, 2021 I'm trying to to set the color of pixels one by one. I have a matrix with all my value, calculate by some function to assign a specific color. Actually i'm using the Geometry Rectangle with size 1x1, but i'm not sure it's the best way to do that. Anyone have some suggestion? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 16, 2021 Share Posted April 16, 2021 "Texture.fromBuffer" . You can later update it with different data. However, it works only with WebGL. If you want canvas, better to handle getImageData/setImageData and use `Texture.from(myCanvas)`, and call "texture.update()" every time you change something Snok 1 Quote Link to comment Share on other sites More sharing options...
Snok Posted April 16, 2021 Author Share Posted April 16, 2021 Thanks ! i'll try this way. It's ok only WebGL, perfect! Quote Link to comment Share on other sites More sharing options...
Snok Posted April 21, 2021 Author Share Posted April 21, 2021 I've another question =D I've implemented my work with the Texture.fromBuffer and it works fine. I compute my texture with the cpu for every 'pixel' and after i render it. There is a way for me with pixi and webGL to pass some data to the pixel and delegate the work to each one to compute every pixel in parallel?! Because i need to compute my texture frequently with different data and i thought some way to optimize my code with cpu, but of course if i do the work with gpu it will be faster. (the data that i need to pass to the pixel every time it's a different amount) . Thanks, i hope it's not a stupid question Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 21, 2021 Share Posted April 21, 2021 mesh-shader + renderTexture. If you know how to put your stuff into shader, you can do it. https://pixijs.io/examples/#/mesh-and-shaders/triangle-color.js Snok 1 Quote Link to comment Share on other sites More sharing options...
Snok Posted April 22, 2021 Author Share Posted April 22, 2021 Perfect! Thanks , I read somethings about mesh and shader before, now that i'm sure that it's the way i'll try to go more inside ✌️ Thanks a lot for all your advice ! Have a nice day! 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.