问题描述
我想知道是否有人拥有完整,可运行且有效的代码来在glsl中进行双三次纹理过滤.有这个:
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-Cubic-and-Bi-Linear-Interpolation-with-GLSL 或者 https://github.com. com/visionworkbench/visionworkbench/blob/master/src/vw/GPU/Shaders/Interp/interpolation-bicubic.glsl
但是两者都执行16次纹理读取,而其中只有4次是必需的:
but both do 16 texture reads where only 4 are necessary:
https://groups.google.com/forum/#!topic/comp.graphics.api.opengl/kqrujgJfTxo
但是,上述方法使用了一个我不知道该怎么做的缺失的"cubic()"函数,并且还使用了一个无法解释的"texscale"参数.
However the method above uses a missing "cubic()" function that I don't know what it is supposed to do, and also takes an unexplained "texscale" parameter.
还有NVidia版本:
There is also the NVidia version:
但是我相信这使用的是CUDA,它专用于NVidia的显卡.我需要glsl.
but I believe this uses CUDA, which is specific to NVidia's cards. I need glsl.
我可能可以将nvidia版本移植到glsl,但是我想先问一下是否有人已经拥有完整的,可以正常工作的glsl双三次着色器.
I could probably port the nvidia version to glsl, but thought I'd ask first to see if anyone already has a complete, working glsl bicubic shader.
推荐答案
我决定花一点时间来挖掘我以前的Perforce活动,并发现缺少的cube()函数;请享用! :)
I decided to take a minute to dig my old Perforce activities and found the missing cubic() function; enjoy! :)
vec4 cubic(float v)
{
vec4 n = vec4(1.0, 2.0, 3.0, 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);
}
这篇关于GLSL中高效的双三次过滤代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!