【发布时间】:2015-12-23 16:16:09
【问题描述】:
在 WebGL 中,我尝试将 float 1 组件纹理发送到 GPU:
var array = new Float32Array(4096*4096);
// ... read array from file
var float_texture_ext = gl.getExtension('OES_texture_float');
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texImage2D(gl.TEXTURE_2D, 0, 4096, 4096, 0, gl.ALPHA, gl.ALPHA, gl.FLOAT, array);
但它不起作用。在我 PC 上的 Chrome 中,我收到以下警告:
WebGL: INVALID_OPERATION: texImage2D: incompatible format and internalformat
[.WebGLRenderingContext-1A49BCD8]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
我也尝试过 gl.RGBA、gl.RGBA 但得到了相同的结果。
我该怎么做?
【问题讨论】: