旋转GPUImageTiltShiftFilter-GPUImage [英] Rotate GPUImageTiltShiftFilter - GPUImage

查看:111
本文介绍了旋转GPUImageTiltShiftFilter-GPUImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个非水平的GPUImageTiltShiftFilter旋转.我想将其旋转到任意旋转角度.我还希望过滤器速度快,可以使用带有UIRotationGestureRecongizer的UI旋转它.

I want a non-horizontal GPUImageTiltShiftFilter rotation. I want to rotate it to an arbitrary rotation angle. I also want the filter to be fast it can be rotated with a UI with a UIRotationGestureRecongizer.

我该怎么做?

推荐答案

啊,想通了!

代替修改GPUImageTiltShiftFilter,创建一个新的GPUImageFilterGroup作为GPUImageGaussianSelectiveBlurFilter的修改版本以添加旋转.

Instead of modifying GPUImageTiltShiftFilter, make a new GPUImageFilterGroup as a modified version of GPUImageGaussianSelectiveBlurFilter to add rotation.

我添加了:

   uniform highp float rotation;

在kGPUImageSMTiltShiftFragmentShaderString中,我将distanceFromCenter线添加到GPUImageGaussianSelectiveBlurFilter的主行中,以将GPUImageGaussianSelectiveBlurFilter旋转为倾斜移位:

within kGPUImageSMTiltShiftFragmentShaderString, and I added the distanceFromCenter line to the main of GPUImageGaussianSelectiveBlurFilter to turn GPUImageGaussianSelectiveBlurFilter into a tilt shift with rotation:

 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));
 }

这篇关于旋转GPUImageTiltShiftFilter-GPUImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆