Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios GPUImage glsl正弦波photoshop效果_Ios_Glsl_Gpuimage_Trigonometry - Fatal编程技术网

Ios GPUImage glsl正弦波photoshop效果

Ios GPUImage glsl正弦波photoshop效果,ios,glsl,gpuimage,trigonometry,Ios,Glsl,Gpuimage,Trigonometry,我需要实现一个iOS UIImage过滤器/效果,它是Photoshop扭曲波效果的副本。波必须有多个发生器,并在CGRect内以紧密模式重复 附步骤照片 我在创建glsl代码以再现正弦波模式时遇到问题。我还试图平滑效果的边缘,这样到矩形外区域的过渡就不会那么突然了 我发现了一些产生水波的WebGL代码。在中心点之前产生的波浪看起来很接近我所需要的,但我似乎无法正确计算以消除水波纹(在中心点),并在其之前保持重复的正弦模式: varying highp vec2 textureCoord

我需要实现一个iOS UIImage过滤器/效果,它是Photoshop扭曲波效果的副本。波必须有多个发生器,并在CGRect内以紧密模式重复

附步骤照片

我在创建glsl代码以再现正弦波模式时遇到问题。我还试图平滑效果的边缘,这样到矩形外区域的过渡就不会那么突然了

我发现了一些产生水波的WebGL代码。在中心点之前产生的波浪看起来很接近我所需要的,但我似乎无法正确计算以消除水波纹(在中心点),并在其之前保持重复的正弦模式:

 varying highp vec2 textureCoordinate;
 uniform sampler2D inputImageTexture;

 uniform highp float time;
 uniform highp vec2 center;
 uniform highp float angle;

 void main() {
     highp vec2 cPos = -1.0 + 2.0 * gl_FragCoord.xy / center.xy;
     highp float cLength = length(cPos);

     highp vec2 uv = gl_FragCoord.xy/center.xy+(cPos/cLength)*cos(cLength*12.0-time*4.0)*0.03;
     highp vec3 col = texture2D(inputImageTexture,uv).xyz;

     gl_FragColor = vec4(col,1.0);
 }
我必须处理两个矩形区域,一个在顶部,一个在底部。因此,能够在一个过程中处理两个矩形区域将是理想的。加上边缘平滑


提前感谢您的帮助

我以前处理过这个问题,在CPU上生成一个偏移表,并将其作为输入纹理上传。因此,在CPU上,我会执行以下操作:

for (i = 0; i < tableSize; i++)
{
    table [ i ].x = amplitude * sin (i * frequency * 2.0 * M_PI / tableSize + phase);
    table [ i ].y = 0.0;
}
uniform sampler2DRect table;
uniform sampler2DRect inputImage;

//... rest of your code ...

// Get the offset from the table
vec2 coord = glTexCoord [ 0 ].xy;
vec2 newCoord = coord + texture2DRect (table, coord);

// Sample the input image at the offset coordinate
gl_FragColor = texture2DRect (inputImage, newCoord);