UNPKG

pbrtools

Version:
26 lines (23 loc) 1.1 kB
// ======================================================================== // The first method of encoding floats based on: // https://github.com/cscheid/facet/blob/master/src/shade/bits/encode_float.js // // After rendering to RGBA, UNSIGNED_BYTE texture just call gl.readPixels with // an Uint8Array array and cast it to Float32Array. // e.g.: // var output = new Uint8Array(size); // (render to RGBA texture) // gl.readPixels(..., output); // var result = new Float32Array(output.buffer); // // 'result' array should be filled with float values. // readTextureMethod1 = function (tex) { outputTexture.drawTo(function () { tex.bind(); encodeShader1.draw(plane); // format: gl.RGBA, type: gl.UNSIGNED_BYTE - only this set is accepted by WebGL readPixels. gl.readPixels(0, 0, outputTexture.width, outputTexture.height, outputTexture.format, outputTexture.type, outputStorage); outputConverted = new Float32Array(outputStorage.buffer); }); gl.finish();