[quote=“theagentd,post:770,topic:49634”]
running on a nvidia 560TI the bicubic filter takes about 180% the time compared to bilinear. adding up 5 miplevels takes ~ 2ms, quiet expensive (4 texture lookups per pixel). quality is good enough for blooming (subtle, not many contours); using as a pure blur filter, the pattern which is visible from linear mipmaps almost disappears but is still visible.
try yourself
vec4 cubic(float v)
{
vec4 n = vec4(1.0 - v, 2.0 - v, 3.0 - v, 4.0 - v);
vec4 s = n * n * n;
float x = s.x;
float y = s.y - 4.0 * s.x;
float z = s.z - 4.0 * s.y + 6.0 * s.x;
float w = 6.0 - x - y - z;
return vec4(x, y, z, w);
}
vec3 textureBicubic ( const in sampler2D tex, const in vec2 st, const in int mip )
{
vec2 dim = textureSize(tex,mip); // mip > 0 kinda requires this
vec2 idim = 1.0 / dim;
const vec2 off = vec2(-0.5, 1.5);
vec2 dd = st * dim - 0.5;
vec2 fr = fract(dd);
vec2 fl = floor(dd);
vec4 xc = cubic(fr.x);
vec4 yc = cubic(fr.y);
vec4 s = vec4( xc.xz + xc.yw, yc.xz + yc.yw );
vec4 o = (fl.xxyy + off.xyxy + vec4(xc.y, xc.w, yc.y, yc.w) / s) * idim.xxyy;
vec2 m = s.xz / (s.xz + s.yw);
vec3 a = textureLod(tex, o.yw , mip).rgb;
vec3 b = textureLod(tex, o.xw , mip).rgb;
vec3 c = textureLod(tex, o.yz , mip).rgb;
vec3 d = textureLod(tex, o.xz , mip).rgb;
return mix(mix(a,b,m.x),mix(c,d,m.x),m.y);
}