Does GLSL have something like this? If so I haven't found it.

- texelFetch() has the nice property that you can specify texel coordinates directly, but it disables interpolation.
- texture() supports interpolation, but you have to give it normalized 0..1 values not texel coordinates.

I'm using a texture to store/sample a piecewise-linear interpolation function here, and I really want something where you specify texel coordinates directly AND you get the free interpolation supported by the texture sampler. Basically a texelFetch() function that, instead of accepting ivec3 texel coordinates, accepts vec3 texel coordinates (allowing coordinates between texel centers to be specified -- e.g. 15.4).

As a work-around, I need to implement my own "textureFetch()" which mixes the two, calling texture() under-the-hood. But the disadvantage to this being you have to do this ugly texcoord math to map to 0..1 input values, and then map those 0..1 values to texcoords for proper sampling (because the linear function starts at the first texel's center and ends at the last used texel's center):

Code :/** texcoordToLinFunct() - Converts a 0..1 texcoord to a 0.5/N..(M-1)/N * texcoord used to lookup into a texture with normalized texcoords * used to store a linear function. * * \param N - width of texture (in texels) * \param M - "used" width of texture (set to N if using full width) */ vec3 texcoordToLinFunct( vec3 tc, ivec3 N, ivec3 M ) { return tc * (M-1)/float(N) + 0.5/N ; } ivec3 res = textureSize( tex, 0 ); vec3 texel_coords = vec3( val1, val2, val3 ); // Texels units I "really" want to provide to a texture function... vec3 texel_coords_0_to_1 = texel_coords / res; vec3 tc = texcoordToLinFunct( texel_coords_0_to_1, res, res ); vec4 = texture( tex, tc );