Exporting Blender Lens Distortion Using STmaps

Part of using Blender in a professional studio pipeline is being able to matchmove your scene and use that exact camera setup in whatever compositing application you’re working in. And that means dealing with the lens distortion.

Blender does a great job of calculating and correcting that lens distortion, but we haven’t had a great solution for using that correction in other applications. Using Blender’s K1/K2 values in a program like Nuke or Natron does not result in the same undistortion or distortion. That’s a big problem.

Until we have K1/K2 values that work in compositing programs, the only way we have to utilize the exact same lens distortion is to create STmaps in Blender and use them for warping in our compositing programs. Scroll down to the video to see how to do it.

STmaps basically just store warp data as an image, very similar to normal maps and UV maps. Each pixel has it’s own unique value, and we’re able to map the positions of an input image or sequence to those positions, so if they move, the image changes, as well.

You can actually use STmaps for all kinds of things. There’s a great explanation HERE of using it for projections, and there’s a great tool called RE:Map I used years ago in After Effects to be able to replace 3D textures in 2D after the 3D was rendered. (Yes, you can replicate all this in Blender!)

Nuke STmap expressions
r = (x+0.5)/width
g = (x+0.5)/height
Natron STmap expressions
r = (x+0.5)/1920
g = (x+0.5)/1080

Above are the expressions you’ll need for Nuke or Natron to create the base STmap image, and you can see how to use them or how to make the image in Blender in the video below. I hope this helps some folks out there trying to use Blender in a pipeline with other programs. It’s certainly helping me out! Grab the demo files below and check out the video! I’m sharing some footage, the STmaps, and the projects for Blender, Natron, and Nuke.

And thanks to Irfan, Dustin, Brian, and Zeke on twitter for getting this ball rolling and solving some of this!

Assets required:

One comment

Leave a Reply