Perspective in GPUImageTransformFilter
Hi guys,
Have just discovered the GPUImage library and think it is really great and easy to use.
I am using the GPUImageTransformFilter with a CATransform3D, but for some reason the perspective of the transform is not applied when I use the filter on an image (this is usually controlled by the transform.m34 value)
Has anyone else had experience in getting this working?
Michael
Hi Brad, firstly well done on GPUImage. Just came across it and looks like it will be really helpful for an app I'm working on.
Building on the issues of the guy above, I'm trying to understand how GPUImage handles the camera position and vanishing point setting in OpenGL. I need to set these very precisely, and I see openGL has methods like gluLookAt but not sure how or if I can use these together with GPUImage, and if not then how does GPUImage handle these issues.
Thanks, Michael.
All I do is apply a 4x4 transformation matrix to an image. You're going to need to do the same calculations that these perspective functions apply to create their end matrix. Once you have that matrix, you just feed it into the transformation filter.
The math doesn't translate directly across from a CATransform3D used for a Core Animation layer to an OpenGL ES quad, so you have to use slightly different matrix elements for perspective using GPUImage. Look at the 3-D transform example in the FilterShowcase, which applies perspective to a rotating image.
In that case, I needed to set m33 to 0.4 as well as m34 in order to achieve the kind of perspective you expect when doing this in Core Animation.