Offsets Demystified
From Filter Forge Wiki
The most basic function of the Offset node is to move the image relative to its origin.
However, with various inputs the Offset component can be used to achieve almost any transformation of the source image, from scaling and skewing to rotation and perspective transformation, and on to even more fanciful coordinate transformations.
Contents |
Offsets by constants
The Percentage input can be thought of as the "strength" of the offset. If you keep it at 100%, it is easiest to see how the X and Y Offsets work.
Feeding a constant into the X Offset or the Y Offset input moves the image horizontally (left and right) or vertically (up and down) respectively.
Since there are three ways to feed a constant into the inputs, it is important to see how they relate. This diagram attempts to show the relationship:
The center square in the diagram is the actual render area of the filter.
The red numbers are the values in the component itself, that is, if you don't plug anything in to the inputs but change the values directly in the component. (0,0) equals to no offsetting.
The black numbers are numeric slider values. (50,50) equals to no offsetting.
The black to white gradient shows the gray value of a flat color. Mid-gray((128R, 128G, 128B),((128R, 128G, 128B))) or (128K, 128K) equals to no offsetting. [R=red, G=green, B=blue, K=black]
Thus, to offset the image up and the the left, you would change the values smaller, such as in:
In this case, the values would be (-60,-70) in the component itself, (20,15) in the slider inputs or (51K, 38K)[rounded] as flat gray color inputs.
Seamless versus non-seamless
The first "oddity" that can be observed in using the Offset node is the behavior change between the seamless and non-seamless states (as controlled by the Seamless checkbox in the filter settings).
When the Seamless checkbox is checked, the offset image "wraparound" images are rendered in the same direction as the original image. When the checkbox is not checked, the wraparound images are mirrored. It can be a source of endless mysteries unless one knows this.
Let's take a look at how the above works in real life.
Here we have the two numeric sliders plugged into the X and Y Offsets. With these settings the image is in the center.
When we move the X Offset slider to 75, it equals +50 in the component itself. Thus the image offsets by 50%. Notice that the image that fills in to the left is a mirror image of the original.
To make the image appear in the same direction, we have to check the Seamless Tiling checkbox.
Offsets by gradients
Offsets are the key to transforming the original image in various ways. The trick is to input an image into the X and Y Offsets. The first image type we are going to look at is a gradient.
The transformations may not seem very logical at first, but when you know these basics, things start to make sense:
1. BLACK MEANS 100% OFFSET TO THE LEFT (OR UP).
2. GRAY MEANS NO OFFSET.
3. WHITE MEANS 100% OFFSET TO THE RIGHT (OR DOWN).
Other gray values move pixels those in-between amounts.
Let's see how that works.
If we input a horizontal gradient from black to white into X Offset, we get a mirror image of the original. This is because BLACK at the left edge offsets pixels 100% to the left (that is, the right edge is offset there), WHITE at the right edge offsets pixels 100% to the right (the left edge is offset to the right) and the GRAY in the middle stays in the middle.
Now, you would think that flipping the gradient would do the same, only in reverse. However, you end up with three squished copies of the original. Why?
When you walk through it, with the original diagram in view, you can probably see why. The WHITE at the left edge offset pixels 100% to the right. Thus the left edge of the NEXT TILE TO THE LEFT ends up at the left edge of the image. Similarly, BLACK at the right edge offsets pixels 100% to the left, pulling the right edge of the NEXT TILE TO THE RIGHT to the right edge of the image. GRAY in the middle moves nowhere and other values do things in-between. Thus, you end up with three tiles squished into your image. Whether those tiles face the same way or flip-flop depends on whether you have Seamless Tiling turned on or off.
This behavior may take some getting used to, but after some time it can become quite logical.
So, can you see what happens here?
The horizontal mid-point of the image is stretched all the way across the image. This is because we have 25% lightness value at the left edge, which is halfway between black and gray. Thus the image is offset 50% to the left at the left edge. This means the midpoint of the image. In the center, there is gray, so the image is not offset there, and at the right there is 75% lightness value, which is halfway between gray and white, thus offsetting the image 50% to the right at the right edge, which is the horizontal midpoint again. The result is that at every point, the image offsets "reads" the horizontal midpoint of the image.
Identical result can be achieved with a black-to-white gradient by reducing the Percentage control to 50%:
Scaling the image up
Using a gradient in both directions, X and Y, the image can be scaled up or down. If the exact same gradient is used, the image will be scaled proportionately.
Scaling an image up is straightforward. Using white-to-black gradients and changing Percentage input makes it easy.
The image is scaled up when Percentage is between 0 and 50. At 50 the center point of the image fills the entire image area.
From 50 to 100 the image is flipped on both axis and scaled down to the original size at Percentage 100.
Scaling the image down
Scaling the image down is a different animal. If you have followed the logic of the Offset node this far, you may see that flipping the gradients will result in scaling the image down, but only to 1/3 of the original image.
Explaining the following method for scaling an image between 0 and 100% is most likely going to result in a headache, so I am just going to give the settings for it and include the snippet.
The Size Slider has been remapped as follows:
START: Minimum 50, Maximum 0
END: Minimum 50, Maximum 100
MINIMUM: Minimum 75, Maximum 50
MAXIMUM: Minimum 25, Maximum 50
Only one copy of the image is scaled down this way, and you would likely want to mask out the rest of the image in real-life use.
Here's a link to the snippet:
Image:Basic Offset Shrink.ffxml
The "get(x,y)" trick
After being introduced to the complexity of scaling the image down by Offset and gradients, one might wish there was an easier way to use Offsets and gradients. Indeed, there is a trick which makes it so. I call this the "get(x,y)" method.
This snippet takes two input images and converts the gray values to coordinates of the original image. In other words, one image gives the X location in the original where BLACK = 0 (left edge) and WHITE = 100 (right edge), and the other one the Y location in the original, where BLACK = 0 (top edge) and WHITE = 100 (bottom edge).
The output of the snippet retrieves the image from the coordinates given by the two input images.
You can see the beauty and clarity of when you look at how scaling the image down is handled with this method.














