twgl.js
twgl.js copied to clipboard
Example with 'OES_texture_float' and 'WEBGL_color_buffer_float' extensions
We need WebGL1 example with float extensions because WebGL2 will never supported by Apple.
Here working example with 'WEBGL_color_buffer_float' in WebGL1 https://jsfiddle.net/mp6onju8/
And here 'OES_texture_float' in WebGL1 https://jsfiddle.net/7vqehuds/6/
It is right and all of them float32? Do we need to use Float32Array type or something else?
Looks right to me. You can use Float32Array if you want
let texbuffer = new Float32Array(width * height * 4);
let off = 0;
for(let i = 0; i < width; i++) {
for(let j = 0; j < height; j++) {
texbuffer[off++] = (Math.cos(3.14*i/width));
texbuffer[off++] = (Math.sin(3.14*j/width));
texbuffer[off++] = (Math.cos(3.14*j/width));
texbuffer[off++] = (1.0);
}
}
const textures = twgl.createTextures(gl, {
texture: {
format:gl.RGBA,
minMag: gl.NEAREST,
wrap: gl.CLAMP_TO_EDGE,
src: texbuffer,
}});
you should probably check for float support and show warning if no support. 1 out 4 devices don't support it.
Yep