dimanche 20 novembre 2016

How to transform texture of three.js to WebGL

I got two texture objects of position and normal, say,

var tx1 = gpuCompute.getCurrentRenderTarget( positionVariable ).texture;
var tx2 = gpuCompute.getCurrentRenderTarget( normalVariable ).texture;

which is calculated by GPUComputationRenderer from three.js (refer to the example gpgpu/protoplanet (1))

I want to transform it to a WebGLBuffer object for rendering, like:

gl.bindBuffer(gl.ARRAY_BUFFER, tx1);
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, 3, gl.FLOAT, false, 0, 0);

gl.bindBuffer(gl.ARRAY_BUFFER, tx2);
gl.vertexAttribPointer(shaderProgram.vertexNormalAttribute, 3, gl.FLOAT, false, 0, 0);

But the direct assignment is not OK.

I want to ask if there is a way to do it. The snapshot of the format of these two objects is shown as follows (tx1 is from threejs, and tx3 is from WebGL). Thanks.

(1) http://ift.tt/2fRdT0u

enter image description here




Aucun commentaire:

Enregistrer un commentaire