SUMMARY
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 customizable STMap using an Expression node, some simple expressions and a Reformat node.
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)
NOTE: 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:
NOTE: 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
NOTE: 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