webgl - How do I send a float 1 component texture to the GPU? -


in webgl trying send float 1 component texture gpu:

var array = new float32array(4096*4096); // ... read array 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); 

but not working. in chrome on pc following warnings:

webgl: invalid_operation: teximage2d: incompatible format , internalformat [.webglrenderingcontext-1a49bcd8]render warning: texture bound texture unit 0 not renderable. maybe non-power-of-2 , have incompatible texture filtering. 

i tried gl.rgba, gl.rgba got same result.

how do this?

your arguments gl.teximage2d out of order. it's

 gl.teximage2d(target, level, internalformat, width, height,                border, format, type, data); 

also should check result of getting floating point extension because plenty of phones , tablets don't support them should @ least tell user it's not going work.

var ext = gl.getextension("oes_texture_float"); if (!ext) {    alert("this device not support floating point textures"); } 

and, if want linear filtering floating point textures need enable too.

var ext = gl.getextension("oes_texture_float_linear"); if (!ext) {    alert("this device can not filter floating point textures"); } 

note @ point in time (sept 2015) few popular phones support filtering on floating point textures.


Comments