Objective c OpenGL ES 2挤压失真过滤器,如photobooth应用程序
我正在尝试编写一个挤压效果的代码,就像photobooth ios或osx应用程序中的挤压效果一样;我不熟悉着色器,但我能够实现GPUImage库和tweek一些着色器;然而,我所能得到的只是一个球面畸变,最终的结果与我想要得到的有点不同 下面是我从import gpuimageBulgeTransformationFilter.h修改的一些代码 特别是我在使用这个代码Objective c OpenGL ES 2挤压失真过滤器,如photobooth应用程序,objective-c,opengl-es-2.0,Objective C,Opengl Es 2.0,我正在尝试编写一个挤压效果的代码,就像photobooth ios或osx应用程序中的挤压效果一样;我不熟悉着色器,但我能够实现GPUImage库和tweek一些着色器;然而,我所能得到的只是一个球面畸变,最终的结果与我想要得到的有点不同 下面是我从import gpuimageBulgeTransformationFilter.h修改的一些代码 特别是我在使用这个代码 NSString *const kGPUImageBulgeDistortionFragmentShaderStrin
NSString *const kGPUImageBulgeDistortionFragmentShaderString = SHADER_STRING
(
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
uniform highp vec2 center;
uniform highp float radius;
uniform highp float scale;
void main()
{
highp vec2 textureCoordinateToUse = textureCoordinate;
highp float dist = distance(center, textureCoordinate);
highp float PI = 3.14159265358979323846264;//stone added
textureCoordinateToUse -= center;
textureCoordinateToUse.x = 0.5+textureCoordinateToUse.x*cos(textureCoordinateToUse.x*PI/radius)*scale;
textureCoordinateToUse.y = 0.5 + textureCoordinateToUse.y*cos(textureCoordinateToUse.y*PI/radius)*scale;
gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );
}
);
这个代码使用cos、sin和PI,所以它肯定在球形范围内;任何提示,使它更平坦,中间有一个微小的未伸展部分将是一个很大的帮助!p>