is it possible to retrieve pixels value as a float on framebuffer with multiple attachments ? (WebGL 2)
I tried this :
var framebuffer = _gl.createFramebuffer();
_gl.bindFramebuffer(_gl.FRAMEBUFFER, framebuffer);
_gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, texture1, 0);
_gl.framebufferTexture2D(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT1, _gl.TEXTURE_2D, texture2, 0);
_gl.drawBuffers([_gl.COLOR_ATTACHMENT0, _gl.COLOR_ATTACHMENT1]);
With float textures setup as follow :
_gl.texImage2D(_gl.TEXTURE_2D, 0, _gl.RGBA32F, 256, 256, 0, _gl.RGBA, _gl.FLOAT, null);
Then i bind the framebuffer and call readPixels to get values for the first attachment :
_gl.readPixels(0, 0, 1, 256, _gl.RGBA, _gl.FLOAT, 0);
Without float textures, this work but with float textures, the framebuffer stay incomplete.
The WebGL 2 spec seem to say that this should work, I now have some doubt however, it seem that _gl.RGBA32F
seem to be the problem, with an internal format of _gl.RGBA
, it generate incompatible type error.