I'm using WebGL for some image processing, and I'd like my fragment shader to output to a 1 or 2 channel texture. I can attach an RGBA or RGB texture to the framebuffer and output to those successfully. But if I attach a LUMINANCE or LUMINANCE_ALPHA texture to the framebuffer instead, the fb status shows as incomplete and it does not work. Hoping to avoid the unneeded extra texture channels, but not sure if this is possible. Thanks for any suggestions!
If format is changed to gl.RGBA below then it works:
gl.getExtension("OES_texture_float")
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
var format = gl.LUMINANCE;
gl.texImage2D(gl.TEXTURE_2D, 0, format, 512, 512, 0, format, gl.FLOAT, null);
var fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
alert("framebuffer not complete");
}