Nabroski Posted July 5, 2016 Share Posted July 5, 2016 (edited) Hello I kind of stuck to read any data of pixels from the engine My goal is to read and set pixels from textures, just a little hint is probably enough. Thank you all for your time The playground:http://babylonjs-playground.com/#1I5MDT#2 i think i looking for this, but i cant get it to work: Best Edited July 6, 2016 by Nabroski Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 5, 2016 Share Posted July 5, 2016 try this i am sorry i cant get time for complete your PG var ReadTexture = function (txt, w, h) { var gl = document.getElementById('renderCanvas') .getContext("webgl", { preserveDrawingBuffer: true }) || eng.get().canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true }); var fb = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, fb); gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, txt, 0); var pixels = new Uint8Array(w * h * 4); gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels); return pixels; } var readPixel = function (pix, x, y,w ) { return { r: pix[y * 4 * w + x * 4], g: pix[y * 4 * w + x * 4 + 1], b: pix[y * 4 * w + x * 4 + 2], a: pix[y * 4 * w + x * 4 + 3] }; } usage : readPixel( ReadTexture( texture , width,height) ,x, y, width ); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 5, 2016 Share Posted July 5, 2016 Do you want to read from a specific texture or from the rendering? If you want to get the content of the framebuffer, you should have a look at this function: https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.tools.ts#L568 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 27, 2016 Author Share Posted July 27, 2016 I using Dynamic Textures now, to get and set pixels, if any of you has an easy to use Textures RGB example i would high apprentice it. Yeah, Yeah, i learn shades, ....someday. I experimenting with Dump Framebuffer, thank you for the tip. I apply a screenshot now real time to an object, its nice to play with Do you want to read from a specific texture or from the rendering? From the rendering. http://babylonjs-playground.com/#10OY8W#2 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.