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: