Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linear image




On Jun 12, 2005, at 10:20 AM, Pierre-Olivier Latour wrote:

is not very clearly worded on which space what coordinates are in, and when you should try to convert them. A short page describing coordinate systems in QC and/or Core Image, and what functions convert between which spaces, would really help, and if I get to understand it sufficiently, I'll try to write such a page on the wiki.


CI coordinate system is only used with CI filters / kernels as they work with images, not the 3D space: it uses pixels with the (0,0) is at the bottom-left corner

Core Image has a couple of conceptual coordinate spaces:

Working Coordinates: this is the coordinate system that images exist in, you can think of it as an infinitely large board on which you pin images. Use the -imageByApplyingTransform: method or the CIAffineTransform filter to move images around in this space.

Sampler Coordinates: only seen inside the kernels, each "sampler foo" variable (i.e. each texture when rendering with OpenGL) represents some finite subregion of the infinite working space. Point 0,0 is the bottom left corner of the physical texture, one unit is one texel.

So this means that whenever you use the sample () function in a kernel, the point you specify must be in the coordinate space of that sampler object, not in the working coordinate space (the actual pixels in the texture may be flipped vertically, or have a non-zero translation when rendering tiled, or maybe a weird scale factor if the engine moved an affine transform around)

These are the functions that deal with this:

destCoord () -> the current output point, in the working coordinate space.

samplerTransform (x, p) -> working space point p, mapped into the coordinate space of sampler x

samplerCoord (x) -> the current output point, mapped into the coordinate space of sampler x, equivalent to samplerTransform (x, destCoord ())

If you want to forget all these details, create a new sampling function:

vec4 sampleWorking (sampler x, vec2 p) {
  return sample (x, samplerTransform (x, p));
}

then just use working space coordinates everywhere.

    John


_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Linear image (From: Ralph Brunner <email@hidden>)
 >Re: Linear image (From: Sam Kass <email@hidden>)
 >Re: Linear image (From: Pierre-Olivier Latour <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.