This is a noob question but I am stumped. I have a texture that stores x and y velocities. These velocities can be positive or negative so I need a texture that can store negative values. I can make the texture fine:
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8_SNORM, height, width, 0, gl.RGBA, gl.BYTE, null);
The issue is that I want to be able to update the values in the texture but I don't think you can write to the texture using a framebuffer because per the webgl2 documentation textures with negative values are unrenderable.
const fbVelocity = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fbVelocity);
gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, velocityTexture, 0);
Webgl2 returns the error Framebuffer is incomplete: 36054
. That makes sense as the texture type is unrenderable so of course trying to write to it with a frame buffer doesn't work!
My question is how are you supposed to update the texture if you cant use a frame buffer? I saw options of using it as a uniform in a shader that writes to another texture but wouldn't that new texture be unable to store negative values?