nob_reframe (Compatible with IFFS 2025.1.0 and up)

Download this shader

This Matchbox shader reframes a shot with respect to perspective distortion.

The concept of this shader is to simulate a different focal length and camera orientation while maintaining the camera’s position.
Image-wise only spatial transformations are applied to acquire this alternate view, thus brightness is retained and bokeh is transformed with the image (note that this can lead to deformed bokeh when extremely wide source FoV and strong off-centreing come together).

The input , namely , and are all in relation to the undistorted source, including potential (black) padded areas. Thus, depending on the frame of reference, the equivalent and might be larger, or the smaller than what the visible portion is comprised of. The parameter can be omitted if is enabled, and isn't .

The resulting image format can be customized to any canvas resolution as well as frame and pixel aspect ratios. In cases of different frame aspect ratios, the content is automatically scaled to fit the resulting frame height. Downscaling images to smaller formats while applying reframing, rectification and rotation at the same time is a particular strength of this shader, since it applies all operations simultaneously. In contrast to a multi-node pipeline, this circumvents generational loss due to multiple introductions of softness and/or aliasing in the individual steps.
By default, antialiasing is disabled for performance reasons, though it is strongly encouraged to enable it for final output. Filtering is done through either a Box- or a Gauss-Kernel, the former - in combination with a width of 1, corresponding to the default of 0.289 is for retaining perfect sharpness; whereas the latter is better suited towards soft filtering, preventing not only aliasing but also temporal flickering (which might occur for the highest spatial-frequency sources & strong non-integer-ratio downsampling) - values around 0.4 should be a decent starting point. In any case, the samples number should be selected high enough to accommodate for a smooth filtering, for Gauss filtering wit a larger than 0.5, even as high as 4096.

In lens-distortion rectification (un-distortion) and re-distortion workflows, the order of operations matters. Logically, the image is first rectified, then perspectively transformed, and lastly re-distorted (albeit internally, for creating the ST map, those operations are reversed & performed inverted, respectively). The transformation is only correct for undistorted images, hence the rectification module in this shader. Do not attempt to correct existing distortion in -mode, as this would result in incorrect perspective transformations due to wrong order of operations. If the source is free of lens distortion, and no distortion is to be introduced, leave the mode . For mere rectification and modeling distortion-parameters (a checkerboard source is a suitable reference), use -mode. For introducing distortion to undistorted sources, use -mode. If the source lens distortion is to be retained post-transformation, use <Un+Re-Dist.>-mode. Optionally, an external ST map can be used for rectification, fully compatible with those generated by Flame's own node. Note that it is only used if the in is set to or <Un+Re-Dist.> and is enabled. If so, the shader additionally adopts this map's format as the input format instead of Front's. Analogously, if the is set to or <Un+Re-Dist.> and is enabled, an external ST map for re-distorting the image is applied. This is implicitly expected to be of equal format to the output, also fully compatible with as generated by Flame's node.

For enhanced performance, this shader internally uses an ST map representing the aggregate transformation which itself is bilinearly filtered; the nature of which is well behaved for typical use, resulting in negligible interpolation errors. Supersampling then takes place on the application of this ST map.
Note that this may cause a loss of information for border pixels, which would interpolate from sample locations outside the target-frame.
To eliminate this error, one can specify a higher & wider canvas resolution, accommodating the filtering kernel size; to then crop the output to the desired format using the <Resize & Crop> node.
Take care to maintain correct pixel- & frame aspect ratios between reframing & crop. Use the selector if necessary (for certain versions of Flame, the frame aspect ratio can snap to close-but-not-exact presets such as 16:9).

Upressing is best done with other means than this shader. Significant enlargements of image portions to a canvas of equal resolution to the input might also result in strong pixelation.
For this, one can output the intermediate ST map and feed it into an external filter better suited towards upressing. Note that when outputting STs, the Matte output is intentionally left black to incentivize running it too through external filtering.

Adaptive Degradation is supported by this shader, which if active bypasses antialiasing.

This shader is licensed under the terms of the MIT license.

For questions contact:
nobbl211 _at_ gmail.com


Version notes

fixed bug that prevented the lens distortion module from working


Older versions that shader

13th of September this year, around 13:29

Download

fixed bug that prevented the lens distortion module from working

9th of September this year, around 14:40

Download

Reworked Lens Distortion Module to allow for Re-Distortion in addition to Rectification
Introduced support for external maps of Lens Un- and Re-Distortion STs, compatible with Flame’s Lens Distortion node
Redistributed Gauss-Kernel for filtering, leading to better results with fewer samples
Fixed matte transformations and generation (if left unconnected)
Changed Front wrap mode to GL_CLAMP_TO_EDGE, to repeat border pixels in transformations involving out-of-bounds regions, matching unpremultiplied workflows
minor changes and fixes
Breaking change: improved the Rectification algorithm, Lens Distortion Parameters from previous versions of this shader are incompatible

5th of September this year, around 14:29

Download

Smoother Gauss filtering kernel

4th of September this year, around 14:56

Download

Introduced Gauss filtering for antialiasing
as well as minor changes & fixes.

24th of February 2024

Download

iterative update

22th of February 2024

Download

improved processing pipeline through use of texelFetch

21th of February 2024

Download

iterative update


Something wrong with this page or the download?

Contact the site custodians via email, if:

How to get help with this particular shader

Sadly, the custodians likely will not be able to explain to you how a shader works or debug its code, or fix it for you. That is the (volountary) role of the shader author.

If the shader does not work on your system or you have questions about it - read the shader description, and try to find the email address of the shader author. Contact them for any issues – letting them know whether you are on Mac or Linux, what version of IFFS you are running etc. will likely help. Be kind and respectful. If you can't get hold of the author - you can try asking in the Logik forum at logik.tv and ask whether anyone could help you debug a particular shader not working.