旋转GPUImageTiltShiftFilter – GPUImage

我想要一个非水平的GPUImageTiltShiftFilter旋转。 我想旋转到任意的旋转angular度。 我也想要filter是快速的,它可以与UIRotationGestureRecongizer用户界面旋转。

我该怎么做呢?

啊,算出来了!

而不是修改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)); }