转自:http://blog.csdn.net/jxt1234and2010
最近写一个图像缩放的接口,考虑到自己有现成的OpenGL图像处理引擎,还是直接写shader用GPU实现方便。为了效果好一些,采用了双三次插值算法。
算法相关公式可参考这篇文章:
http://blog.csdn.net/lichengyu/article/details/8526629
详细实现代码见:
https://github.com/jxt1234/Simple3D/blob/master/src/GL/GLBicubicWork.cpp
测试代码见:
https://github.com/jxt1234/Simple3D/blob/master/gltest/GLBitmapWorkTest.cpp
要集成到其他项目中,只需要 vertex shader 和 fragment shader 两部分的代码,毕竟不同的图像引擎在如何加载shader,如何传参数,如何上传纹理的逻辑都是不同的。
bicubic.vex
<code class="hljs glsl has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">attribute</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec4</span> pos; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">attribute</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span> tex; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">varying</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span> vTex; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> main(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span>) { <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">gl_Position</span> = pos; vTex = tex; }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li></ul>
生成的 fragment shader:
bicubic.fra
<code class="hljs glsl has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#ifdef GL_ES</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">precision</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">mediump</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//用于手机上时需要添加此句</span> <span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#endif</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">varying</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span> vTex;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//纹理坐标,注意与 vertex shader 中的变量对应</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uniform</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">sampler2D</span> buffer; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uniform</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> uUnit;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//传入原图的宽</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uniform</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> vUnit;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//传入原图的高</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> BiCubicPoly1(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> x, <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> a) { x = <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">abs</span>(x); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> res = (a+<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>))*x*x*x - (a+<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>))*x*x + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">return</span> res; } <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> BiCubicPoly2(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> x, <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> a) { x = <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">abs</span>(x); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> res = a*x*x*x - <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>)*a*x*x + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>)*a*x - <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>)*a; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">return</span> res; } <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> main() { <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span> basic; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span> det; basic = vTex*<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit) - <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>,<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>); det = <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">fract</span>(basic); <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">gl_FragColor</span> = <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec4</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.0</span>,<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.0</span>,<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.0</span>,<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.0</span>) +BiCubicPoly2(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly2(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly2(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly1(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly2(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly1(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly2(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly2(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly1(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly2(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly1(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly1(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly1(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly1(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly1(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly2(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly1(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly2(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly1(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly1(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly1(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly1(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly1(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly2(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly2(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly2(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly2(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly1(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly2(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly1(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) +BiCubicPoly2(det.x-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*BiCubicPoly2(det.y-<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>))*<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">texture2D</span>(buffer, vTex + ( - det + <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>), <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>)))/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">vec2</span>(uUnit, vUnit)) ; }</code>