我想要一个非水平的GPUImageTiltShiftFilter旋转。我想将它旋转到任意旋转角度。我还希望过滤器快速,可以使用带有UIRotationGestureRecongizer的UI旋转。
我该怎么做?
答案 0 :(得分:0)
啊,想通了!
不要修改GPUImageTiltShiftFilter,而是将新的GPUImageFilterGroup作为GPUImageGaussianSelectiveBlurFilter的修改版本来添加旋转。
我补充说:
uniform highp float rotation;
在kGPUImageSMTiltShiftFragmentShaderString中,我将distanceFromCenter行添加到GPUImageGaussianSelectiveBlurFilter的主要内容,将GPUImageGaussianSelectiveBlurFilter转换为旋转的倾斜移位:
void main()
{
lowp vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);
lowp vec4 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2);
highp vec2 textureCoordinateToUse = vec2(textureCoordinate2.x, (textureCoordinate2.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
highp float distanceFromCenter = abs((textureCoordinate2.x - excludeCirclePoint.x) * aspectRatio*cos(rotation) + (textureCoordinate2.y-excludeCirclePoint.y)*sin(rotation));
gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(excludeCircleRadius - excludeBlurSize, excludeCircleRadius, distanceFromCenter));
}