I’m writing a volume rendering engine and I want to use cubic interpolation as described in http://wwwvis.informatik.uni-stuttgart.de/vmv01/dl/papers/8.pdf. I managed to get this algorithm working (in 2D for now), but there is a problem:
I have two textures, ‘A’ is texture to be filtered and B is single ‘tile’ of filter kernel. In each pass the filtered texture is mapped onto a quad (say it’s extending from (0,0) to (1,1)) with texture coordinates also (0,0), (1,1) (these coords are actually differently translated in each pass, but it’s not important here). It’s modulated with texture ‘B’, which is repeated across the quad so one ‘instance’ of ‘B’ covers exactly one texel of ‘A’. Texture 'A’s filter is set to GL_NEAREST and 'B’s to GL_LINEAR. But texture ‘B’ has different luminance levels on opposite edges (white and black), so 'B’s texels along 'B’s edges undesirably interpolate with neighbouring ‘instances’. How can I avoid this?
Notice: texture ‘B’ must be GL_REPEAT’ed along the quad (that’s the point of algorithm used) and definitely should be linearly interpolated (with GL_NEAREST problem disappears of course). But I want single ‘instance’ of ‘B’ to behave like it was GL_CLAMP_TO_EDGE’d.
‘Shrink texture coordinates so that border texels are not drawn’ trick won’t work (texture is repeated and it wouldn’t cover A’s texels), nor texture with pixel borders (it falls back to software on my R9600 Pro).
Thanks in advance for any suggestions.