Efficient Bicubic filtering code in GLSL?

前端 未结 8 1822
感动是毒
感动是毒 2021-01-30 06:11

I\'m wondering if anyone has complete, working, and efficient code to do bicubic texture filtering in glsl. There is this:

http://www.codeproject.com/Articles/236394/Bi-

8条回答
  •  天涯浪人
    2021-01-30 06:30

    The missing function cubic() in JAre's answer could look like this:

    vec4 cubic(float x)
    {
        float x2 = x * x;
        float x3 = x2 * x;
        vec4 w;
        w.x =   -x3 + 3*x2 - 3*x + 1;
        w.y =  3*x3 - 6*x2       + 4;
        w.z = -3*x3 + 3*x2 + 3*x + 1;
        w.w =  x3;
        return w / 6.f;
    }
    

    It returns the four weights for cubic B-Spline.

    It is all explained in NVidia Gems.

提交回复
热议问题