# Texel linear interpolation: restricted by texture's bit depth?

as texture2DRect (I use rectangular textures) return float values, I assumed the linear interpolation between texels was computed with a float precision (even if the texture was stored with RGBA8).
I was surprised to see that it wasn’t the case, I cannot get a smooth transition between 0/255 and 1/255: the linear interpolation between theses 2 values return 0/255 and not something like 0.xxx/255.

Is there any way to change that ?

You might ask why I need such a precision, but I’m using the gpu for non-graphic applications and if I could fix this problem without changing to float storage (I already use very large textures and I don’t want to overflow), that would be quite nice.

Thanks

In case of the RGBA8 the texture unit likely does (for performance reasons) the interpolation on the 8bit original values and only converts the result into the float.

You can work around that by point sampling the four texels around the position and calculating the interpolation in the shader.

You could always do the interpolation yourself. (ie use point sampling, sample 4 points based on the texture coordinate and interpolate manually)

I was surprised to see that it wasn’t the case, I cannot get a smooth transition between 0/255 and 1/255: the linear interpolation between theses 2 values return 0/255 and not something like 0.xxx/255.
Where exactly did you sample between the two texels?
How did you obtain the resulting 0 value?
If you wrote it to a fixed point RGBA8 buffer again and read that, I wouldn’t be too surprised.

Eight bits for the interpolators can’t be true, it’s at least 9.
I would expect more like 12 or 16 bits precison though.

Eight bits for the interpolators can’t be true
Interpolating values produced by vertex processor (texture coordinates, vertex color, etc.) requires reasonable precision, but interpolating color when sampling a texture does not. It’s just like: mix(sample1, sample2, weight) - all arguments can be 8-bit and output can be 8-bit.
I believe that sampling 8-bit texture component will use 8-bit interpolator producing 8-bit output. Before shaders were introduced this was all that was needed.

Thanks all.

According to this board: