Re: Core Image in FxPlug example
site_archiver@lists.apple.com Delivered-To: pro-apps-dev@lists.apple.com Darrin On Apr 28, 2009, at 12:24 PM, Darrin Cardani wrote: Darrin On Apr 28, 2009, at 12:16 PM, Darrin Cardani wrote: Darrin On Apr 28, 2009, at 9:53 AM, Patrick Sheffield wrote: I am confused, Patrick On Apr 28, 2009, at 9:01 AM, Darrin Cardani wrote: 0.75 0.89 0.23 0.52 It takes (0.75 - 0.89) = -0.14 as the x offset It takes (0.75 - 0.23) = .52 as the y offset Does that make sense? Darrin On Apr 27, 2009, at 5:53 PM, Patrick Sheffield wrote: Thank you Darrin - this helps a lot. Thanks, -- Darrin Cardani dcardani@apple.com -- Darrin Cardani dcardani@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/pro-apps-dev/dcardani%40apple.com -- Darrin Cardani dcardani@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/pro-apps-dev/dcardani%40apple.com -- Darrin Cardani dcardani@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/pro-apps-dev/site_archiver%40lists.ap... I should also mention, that it uses the red channel for x offset and the green channel for y offset. Here's a simple Core Image kernel that does a displacement. You could either put this into a QC Composition with a "Core Image Filter" object, or write an actual ImageUnit which you then load in your FxPlug: kernel vec4 Displacement (sampler image, sampler mapImage, float scale) { vec4 offset = sample (mapImage, samplerCoord (mapImage)); offset *= scale; return sample(image, samplerCoord(image) + offset.xy); } It's not too inefficient. It reads the current pixel, the next pixel to the right, and the next pixel below. It's 3 samples, which should work relatively efficiently going all the way back to the ATI 9600. Many of the filters we ship with Motion and FCP do similar things. Check out Glass Distortion, Displace, Bump Map, etc. for example. In any event, it's probably not possible to make it work the way you want as it is. It would probably be easier to write a little CoreImage filter right in Quartz Composer, and then use the QC example that was posted earlier today. I'll see if I can come up with a very simple example to help you out. So - it requires 4 pixels to determine which direction to shift each pixel? How can that work? Does it scan starting at the upper left and take the pixel and its right most and then the two pixels below it to determine where to move the first pixel? and how could I even build such a buffer, since the value that was subtracted to determine the first pixel's displacement is being subtracted FROM to determine the second pixel. And what happens at the right/ bottom edges? Seems FRIGHTFULLY inefficient... why not use the RGBA values for this? Glad it helps! It looks to me like Displacement Distortion is using the magnitude and direction of edges in the map image to offset pixels in the source image. I believe it first converts the map image to grayscale, then finds the difference of each pixel with its neighbors in the x and y directions. It multiplies the x and y differences by the scale parameter and uses the resulting vector as an offset from the current pixel in the source image. So let's say the grayscale version of your map image looked like this: It then multiplies those values by the scale parameter. Let's say it's set to 25, so it comes up with an offset of (-3.5, 13). It adds that to the current (x,y) coordinate and samples the input image at (x - 3.5, y + 13). I wonder if you could shed some light on a specific CoreImage filter - specifically DisplacementDistortion... In Shake and in FxScript, the X-Displacement is governed by one channel in the displace image and the Y-Displacement by another. I can't find any documentation on the CI filter as to how it handles this. Patrick This email sent to dcardani@apple.com This email sent to dcardani@apple.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Darrin Cardani