How to implement Drag Distortion Image filter in android?

六月ゝ 毕业季﹏ 提交于 2019-12-03 01:41:28

One way to achieve it is to use an additional texture to specify to the fragment shader the deformation to apply. You can modify that texture contents from the app as the user touches the image to apply deformations.

GPUImageBulgeDistortionFilter extends GPUImageFilter which is designed to use only one texture.

You'll need to duplicate the texture binding (glBindTexture) and assignation to the fragment shader (glUniform1i) in GPUImageFilter using 1 for the new texture (instead of 0). You'll need also to duplicate glGetUniformLocation and use other name instead of inputImageTexture, for example inputImageTexture2.

Modify the fragment shader at GPUImageBulgeDistortionFilter or create a new class derived from GPUImageBulgeDistortionFilter to add "uniform sampler2D inputImageTexture2;\n" +

Finally add code to use inputImageTexture2 texels to deform data at inputImageTexture in the same fragment shader.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!