Create a ticket

Q100448: Creating a custom STMap image in Nuke


Using an STMap is an efficient way to be able to calculate pixel changes within an image. This calculation is based on the combination of two channels that define where each pixel within the resulting image is coming from, based on the input image.

STMaps can be used for a variety of purposes within (and outside) of Nuke and it is important to be able to know how to create these within Nuke itself.

This article explains a simple way to create a customisable STMap using an Expression node, some simple expressions and a Reformat node.



An STMap is a combination of two coloured 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 of the input image.

The purpose of an STMap is not related to the colour itself, rather to the x and y coordinate that each pixel is given. When the two images are combined into the colour 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-aligning images/textures, through to being used as a base for tracking a 2D object to 3D geometry.

Outside of Nuke, they can also be baked in as a texture to a 3D object directly, through to being used to correlate lens distortions to and from other applications to Nuke.



Setting up the Expression node

The Expression node will be used to plot the x and y coordinates to an image, based on the red and green channels. To do this:

1) Create an Expression node in the Node Graph

2) Within the first channel allocated to the red channel, enter the following expression


3) Within the second channel allocated to the green channel, enter the following expression



The result as seen in the Viewer will be the following image:


NOTE: The resolution of the STMap is driven by the resolution of the project. This can be altered through the creation of a Reformat node as an input to the Expression node.



Rendering out the STMap

The last step is to render out the STMap. This will allow to either bring it back into Nuke, or use it within a third party application.

To do this:

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


NOTE: We use a 32-bit depth EXR file as the STMap's calculation is not based upon the output colour, 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.



More information on the functionality of the STMap itself can be found in our Online Help here: 

STMap node
Working with STMaps 


Was this article helpful?

We're sorry to hear that!

Please tell us why.
0 out of 0 found this helpful