2015-10-06 57 views
2

我正在改变顶点着色器内某些顶点的位置,但是我找不到一种方法让这些新的更新顶点位置回到js中(我目前正在使用THREE.js:我的网格顶点的顶点位置始终保持不变)。 我发现这个链接Retrieve Vertices Data in THREE.js,但glGetTexImage不存在于webgl(我也很怀疑这个浮点纹理方法)。 感谢您的帮助!在THREE.js顶点着色器之后得到变换后的顶点位置

+0

请包含您尝试过的代码。 –

回答

0

如果从缓冲区中读取的数据是唯一的问题,你可以是这样做的:

//render the pass into the buffer 
renderer.render(rttScene, rttCamera, rttTexture, true); 

// ... 


//allocate an array to take the data from the buffer 
var width = rttTexture.width; 
var height = rttTexture.height; 
var pixels = new Uint8Array(4 * width * height); 


//get gl context bind buffers, read pixels 
var gl = renderer.context; 
var framebuffer = rttTexture.__webglFramebuffer; 
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);   
gl.viewport(0, 0, width, height); 
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels); 
gl.bindFramebuffer(gl.FRAMEBUFFER, null); 

WebGL - reading pixel data from render buffer

但设置这一切起来是复杂的,和读取纹理可能很慢,为什么不在CPU上做这件事?

+0

感谢您的回复。即使我没有测试从缓冲区读取数据,我明白我的方法是错误的(从我到处都是我的搜索,我仍然不确定我是否可能错过了有关gpu/cpu关系的内容)。无论如何,我接受你的答案。 – user3018088

相关问题