PDA

View Full Version : texel linear interpolation: restricted by texture's bit depth ?



divide
09-06-2006, 05:02 AM
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

Komat
09-06-2006, 05:22 AM
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.

sqrt[-1]
09-06-2006, 05:38 AM
You could always do the interpolation yourself. (ie use point sampling, sample 4 points based on the texture coordinate and interpolate manually)

Relic
09-06-2006, 07:21 AM
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.

k_szczech
09-06-2006, 08:33 AM
Eight bits for the interpolators can't be trueInterpolating 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.

divide
09-09-2006, 08:38 AM
Thanks all.

According to this board:
http://download.nvidia.com/developer/OpenGL_Texture_Formats/nv_ogl_texture_formats.pdf
nVidia's gpus (and ATI's too I guess) don't actually support RGBA16 (it's converted into RGBA8). So I'll have to compute myself the interpolation as Komat and sqrt[-1] suggested :p (a few more texture access..)