skip to Main Content
Updated! Lens Distortion Workflow

Updated! Lens distortion workflow

UPDATE: This is a workaround for something that has now been implemented in PFTrack 2016. You can read about that here: Its works in the same way but is now A LOT easier! 🙂


So a while back I did a blog about lens distortion using PFTrack. And even though still valid I think a better way of doing things now will be to render distorted in the first place.

Why render distorted?

There are three main reasons:

  1. Keeps your distorted corners crisp.
  2. Simplifies comp.
  3. No plugins!

The issue is, when you re-distort post render, you are basically stretching single pixels to distort the frame to match the original plate. This causes softening around the edges which is horrible when it comes to set extensions, especially if its anamorphic! So when you render distorted, its as if your rendering through a physical glass lens, meaning your image is distorted but with the benefit of perfectly sharp edges. This gives you control in comp to soften however you like.

Now also, when your in comp it can get very confusing (especially for junior artists, and even senior artist) having to deal with undistorting and distorting. Sometimes the resolution changes on a per shot basis and things get even more crazy! So this way the matchmover deals with all the distortion and all comp get is a render thats the same resolution as the back plate, distorted, ready to slap on top of the original plate. As an added bonus this means you don’t have to deal with installing plugins for various tracking software, awesome!

Whats the process?

I’ve figured this out with both 3dequalizer and also PFTrack and both work basically the same way, which I’ll explain. 3dequalizer is a lot simpler but both work. My guess is you can probably do this with most tracking software, I’ve only tested it with these two so far.

Create Identity UV Map – Tool (from 3de guys)

Once installed (read in the notes below) this is pretty much all there is too it:


create_identity_uv_map (this calls up the script) -out uvmap.exr (this specifies the name of the file) -size “1920 1080” (this is the output resolution)

All you need to do is navigate to where you want the file to be output before running the command.


  1. Solve your camera, along with your lens distortion
  2. Open up warp4
  3. Export out your undistorted plate for 3d
  4. Generate your UV map with the ‘Create Identity Tool’ at the original plate resolution (this is the part thats different to pftrack) using 3dequalizers software (I’ll explain below)
  5. Replace your input in warp4 with the UV map and change it from ‘Remove distortion’ to ‘Apply distortion’
  6. Export this out as a 32bit EXR


*Sometimes the UV map looks just like a black and white gradient, think this is a bug in 3de but it makes no difference to us, just a display thing.


  1. Track and solve your camera however you like
  2. Export out your camera and undistorted backplate like normal
  3. Note down the undistorted resolution, it will be slightly different
  4. At the end of your tracking tree, add an ‘Apply Distortion’ node
  5. Now generate a UV map with the ‘Create Identity Tool’ the same way as with 3dequalizer, using their software, but at the undistorted resolution noted earlier
  6. Bring in this UV map and plug it into the second input of your Apply Distortion node
  7. You should now have a UV map distorted back to the original resolution
  8. Add a Export node after this and write out the UV map as a 32bit EXR



  1. Now in 3d (tested with Maya/Max) import in that tracking scene along with your undistorted backplate
  2. Add the vray physical camera attribute to your camera
  3. In the extra attributes find the distortion type menu and change it to texture
  4. Load in your UV map
  5. Now when you render your camera will be distorted.

*You can check this is working correctly by rendering your undistorted backplate and comparing it to the original, if nothing changed (apart from some softening where the image is getting resampled) then all is good!


  1. In nuke simply bring in your render and A over B!

If you want to use the UV map to distort in Nuke instead of in the render then just use the STMap node and it will distort the image. This is the normal method so you will still get softening but its still a better way of doing things as it means you don’t need plugins. Also if you are using the “apply distortion in comp” method then render at the overscanned resolution for pftrack and the normal plate resolution for 3dequalzer, its just how they deal with it.



A thing I found, the UV map exported from PFTrack sometimes crashed my Nuke when connecting it to the STMap, all I did was shuffle out the channels leaving just the red and green and it seemed to fix the issue, as below:


Things to note

  • Zoom lenses work exactly the same, you just render a sequence of UV maps instead of just one, as your distortion is going to vary throughout the zoom.
  • DO NOT CREATE YOUR UV MAP WITH NUKE. This is something that tripped me up, if you do this you will find there is a half pixel offset in all directions of distortion. I didn’t read too much into it but its something to do with Nuke reading pixel information from the bottom left corner, whereas we need to read from the centre of the pixel, the ‘Lens distortion plugin kit’ from 3dequalizer is free to download here: for windows, linux and mac. Its a shell command thats simple to use if you read the help that it displays in the terminal.
  • I’ve also heard of issues in Nuke with sampling when post distorting with the UV map, causing stepping in the image, I haven’t witnessed this myself but will update if I find the reason.
This Post Has 25 Comments
  1. Hi Daniel,

    thanks for the tutorial (Updated! Lens distortion workflow) I have a question tho ,

    please could you outline how to generate the uvmap in PF Track, is it a particular node ? you’ve said not to create it in nuke and it seems your suggesting it can be generated in both versions of cam track software, Ive been scanning through the help files for pftrack and haven’t found anything leading to an answer as yet,

    kind regards

    1. Hey mate,

      You need to generate the map in this tool: Create Identity UV Map

      There is a section that explains it roughly. And the download link is down the bottom of the page for it. Use that to generate your UV map and then use it in pftrack or 3de.

      I’ll reorganise the post as its a tad confusing I think. I just brain dumped it haha

  2. Hi!

    First of I want to thank you for sharing this wonderful workflow. It really has saved our asses in our current project.

    Second I wonder how you would go about undistorting footage in PFTrack (to make a more accurate camera solve) using the UV-map we distorted in Nuke.

    We want to be able to use the same UV-map we’ve created in Nuke in both Maya, PFTrack and Nuke. We had some issues with PFBarrel, so that’s out of the question. Is it possible to, say, use the UV-map with the Undistort node?

    Best regards

    1. Glad it could help mate. First thing, I would never undistort my footage in anything other than the tracking package your using. As if you track on an undistorted plate and later realise the distortion is wrong you’ll have to retrack everything from scratch. But also there isn’t a way of using nukes UV map in pftrack as they generate the map differently. Nuke reads the data from the bottom left of each pixel where as tracking software read from centre pixel. So youll get a half pixel shift. The way to do it would be generate your UV map with the tool I mentioned from the 3de guys and then solve your distortion in pftrack and apply it to the UV map. That way you can distort your render in nuke with just the stmap node. No plugins!

      1. Hello again, Daniel!

        Just wanted to tell you that everything is working wonders now! We’re able to generate the distorted UV-map in PFTrack and use it in both Vray and Nuke. It feels wonderful to have the exact same values everywhere with minimal effort and to render out pre-distorted, pixel perfect 3d renders!

        A big thank you to you, sir!

        1. Hey Edvin, thanks for the kind words. Is your process the same as I’ve got down or have you got a custom tool to generate your UV map inside pftrack? Just incase you’ve done something differently that’s easier?

          Cheers 🙂

          1. Hi, Daniel!

            The workflow is just the same as yours. It was really easy once we figured out how to run the script in terminal/cmd.

            Take care!

  3. Hey Daniel!

    Thank you so much for this tutorial! However I hope you can help me with something. I can’t for the life of me, figure out how to run “create_identity_uv_map” script. If I directly open it with Terminal the code runs, but than it writes “[Process completed]” and I can’t write anything else in that window. If I drag and drop it in an empty Terminal window and run it, it allows me to enter the command, but it throws out “-bash: create_identity_uv_map: command not found”.

    Could you point me in the right direction? 🙂

    1. Hey mate, the script has to be called up as a command. So you need to add the script into your default scripts folder or add a custom bath to your bash file so it know where to look. I don’t know what os your using but look up, adding custom scripts to windows/osx/Linux etc should find plenty on what to do 🙂 all the best!

      1. Thank you so much for your help! I added the script to /usr/bin (I’m on osx) and ran the script, but it still would not produce the .exr file – the script just re-ran itself. So after much trial and error I finally figured out that the symbol for output resolution: “ which I copy/pasted from above, is different than the one in the script’s help: “. So after I entered the right one, it finally worked!

        Thanks again for everything! 🙂

  4. Hey Daniel,

    Did you ever figure out what causes the stepping in Nuke with the STMAPS.

    We are having issues when we export out of 3DEqializer

    Any help would be appreciated

    1. Ive never seen the issue myself but a senior compositor mentioned he’s had the issue before. So if you find any fixes please post them up. I can’t think of anything off the bat that it could be? Your using the tool to generate your UV map, not Nuke, right?

    1. Hi Daniel,

      just wondering if for the people who use AE for comping, what method do you recommend on how the apply distortion of the CG pass to match the plate lens curvature using ST-Maps?

      I’ve tried to research this but the only thing that’s available is RE:Maps from Revision Effects.

      1. I’m not an after effects user but I believe the pfbarrel plugin works just fine for AE. This will then allow you to read the pfbarrel (.pfb) files out of pftrack. Hopefully that helps 🙂

        1. They discontinued PFBarrel for After Effects some years ago and it’s no longer compatible.

          Wondering if anyone has found a workflow for using STMaps or other data out of PFTrack in After Effects?

  5. Hi,
    Great article.
    Just to add to your post, it is possible to Create the UV map in nuke without the pixel shift with the following expression:
    r = (x+.5)/width
    g= (y+.5)/height

    As for the edges problem when using the STmap node, this is a known problem and is due to the way STmap works. The node Simply says “This pixel should be the color of the input pixel at coordinate X,Y”, which basically results in 1 sample per pixel, or no Anti-aliasing.
    The workaround for it is to work with larger UV/STmaps and scale down afterwards (at double res you get 4 samples per pixel, which would improve the results considerably).


  6. Hi,
    I can’t seem to run the Create Identity UV Map.
    I can’t seem to get it to work
    Please provide a step-by-step guide and assist.
    Thank you

    Working on windows

    1. Hey Es,

      I would highly advice just upgrading pftrack to get the uvmaps export functionality. This was a massive workaround till the feature was added. Now you can export out uvmaps in a matter of seconds.

  7. Hi Dan,

    Those blocky / tearing artifacts might be due to filtering on the STmap node. I find that ‘cubic’ seems to work well, albeit with some softness in the final re-distorted image.

    Great blog post! Thanks so much for spelling it all out for us so clearly.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top
Close search