SUMMARY
An STMap is a combination of two colored ramps that give each pixel a unique x and y coordinate in 2D space. The red channel encodes the x coordinate and the green channel encodes the y coordinate. STMaps can be used to alter and re-align images, track 2D objects to 3D geometry, correlate lens distortions between applications, and more.
This article explains how to create a basic, customizable STMap using an Expression node, some simple expressions and a Reformat node.
How do I create one?
- Create an Expression node. In the red channel field enter
x/(width-1), and in the green channel field entery/(height-1). The -1 ensures the channels range from (0,0) to (1,1). - Optionally connect a Reformat node to the Expression node's input to control the STMap's resolution independently of the project settings.
- Connect a Write node, set the output format to .exr, and set the datatype to 32-bit float before rendering.
Why 32-bit float? The STMap's value is based on pixel coordinate precision, not color. A 32-bit EXR preserves the full range of coordinate data needed for accurate remapping.
MORE INFORMATION
An STMap is a combination of two colored ramps that provide each pixel a unique x and y coordinate in 2D space. One ramp defines the amount of pixels within the height x and the other in the width y of the input image.
The purpose of an STMap is not related to the color itself, rather to the x and y coordinate that each pixel is given. When the two images are combined into the color channels of green and red, you get the following visual result:
STMaps have a variety of uses within Nuke. They can be used to alter and re-align images/textures, through to being used as a base for tracking a 2D object to 3D geometry.
Outside of Nuke, they can be baked in as a texture to a 3D object directly, to also being used for correlating lens distortions between other applications and Nuke.
WORKFLOW
Setting up the Expression node:
The Expression node can be used to plot the x and y coordinates to an image's red and green channels.
1) Create an Expression node in the Node Graph
2) Within the first field allocated to the red channel, enter the following expression:
x/(width-1)3) In the second field allocated to the green channel, enter the following expression:
y/(height-1)The -1 in the divisors ensures that the image's red and green channels will range from (0,0) to (1,1), instead of (0, 0) to (width-1/width, height-1/height).
The result as seen in the Viewer will be the following image:
The resolution of the STMap is driven by the resolution of the Project. This can be altered by adding a Reformat node to the Expression node's input, like so:
Rendering out the STMap:
The last step is to render out the STMap. This will allow you to either bring it back into Nuke, or use it within a third party application.
1) Create a Write node
2) In the Properties Bin for the Write node, select the file directory for the STMap ensuring that the extension is set to .exr
3) Before rendering ensure that you alter the datatype value to 32 bit float
We use a 32-bit depth EXR file as the STMap's calculation is not based upon the output color, but the amount of pixel variance the EXR file can hold. It may not be visually different, but the difference in information is quite significant and will show in the result.
FURTHER READING
More information on the functionality of the STMap itself can be found in our online documentation below:
In addition to the above, generating an STMap can be done with the CaraVR nodes in Nuke by using the C_GenerateMap or C_STMap nodes. More information on how to create these nodes can be located in the links provided here:
EXAMPLE FILE
We're sorry to hear that
Please tell us why