I'm creating a program where I'm using the GPU to do computations (via fragment shaders) and need to store signed values inside textures.
My texture is initialized with GL_FLOAT, like so:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, nullptr);
And from what I understand about opengl, individual texels must be in the range [0,1] when GL_FLOAT is used (when I experimented with glClear, my values would be clipped to this range). So what I've been doing so far is scaling my values down to the range [-1,1] based on their actual range, then converting that to [0,1] before writing it back to the texture. The next shader that needs to work with the data reads the texel value and moves it to [-1,1] before continuing and so on...
My question is, is this the right way to deal with negative values? I'm pretty sure the repeated conversions are causing fp errors to accumulate which obviously isn't good for accuracy.
Thank you