Jump to: Board index » General » Fusion

Lens Distortion STMap

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

trackster

  • Posts: 5
  • Joined: Sun Feb 25, 2018 1:36 am
  • Real Name: Matt Ralph

Lens Distortion STMap

PostTue Apr 10, 2018 4:31 pm

Hi, I'm having trouble trying to figure out a method to share Lens Distortion values between Fusion and Nuke.

I'm a tracking artist. I can track a shot in 3DEqualizer, export the lens_distortion data from 3DE to Fusion and have it work. But I need to be able to create distortion maps (STMaps in Nuke) to share between the programs so that my Nuke users can undistort / redistort their elements to match what's being done in Fusion.

Fusion has an option to export a distortion map in the lensDistort node. But it wants to export a swirl. I need it to export a ramped UV style red/green/yellow exr image instead that contains the same values so we can use it as an STMap in nuke.

I've messed around with the texture nodes, and displacement nodes, and trying to add expressions in channels but I don't know enough about Fusion to make this work properly. And nothing I've found online seems to work.

Any ideas / advice / examples would be greatly appreciated. FWIW I'm using the Free version of Fusion9. Thanks everyone.

m
Offline
User avatar

Bryan Ray

  • Posts: 661
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Lens Distortion STMap

PostTue Apr 10, 2018 6:16 pm

I haven't really had the time to explore Fusion's lens distortion workflow, but a notion I had the other day was to set up your own STMap grads with Background tools and simply use the Lens Distort node to modify those instead of trying to use the Distortion Map that Lens Distort sends out:

Code: Select all
{
   Tools = ordered() {
      ChannelBooleans1_1_5 = ChannelBoolean {
         CustomData = {
            Settings = {
               [1] = {
                  Tools = ordered() {
                     ChannelBooleans1_1 = ChannelBoolean {
                        Inputs = {
                           Background = Input {
                              SourceOp = "RsAmbientOcclusion_090_MonumentValley_Car_BTY_",
                              Source = "Output"
                           }
                        },
                        Name = "ChannelBooleans1_1",
                        CtrlWZoom = false,
                        ViewInfo = OperatorInfo { Pos = { 440, -313.5 } },
                        CustomData = {
                        }
                     }
                  }
               },
            }
         },
         Inputs = {
            ToRed = Input { Value = 5, },
            ToBlue = Input { Value = 15, },
            ToAlpha = Input { Value = 15, },
            Background = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
            Foreground = Input {
               SourceOp = "Background2",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 715, 82.5 } },
      },
      LensDistort1 = LensDistort {
         Inputs = {
            LensDistortionModel = Input { Value = 1, },
            ["DEClassicLDModel.Distortion"] = Input { Value = 0.0981, },
            Input = Input {
               SourceOp = "ChannelBooleans1_1_5",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 935, 82.5 } },
      },
      Background2 = Background {
         Inputs = {
            GlobalIn = Input { Value = 1, },
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Type = Input { Value = FuID { "Vertical" }, },
            BottomLeftGreen = Input { Value = 1, },
         },
         ViewInfo = OperatorInfo { Pos = { 605, 115.5 } },
      },
      Background1 = Background {
         Inputs = {
            GlobalIn = Input { Value = 1, },
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Type = Input { Value = FuID { "Horizontal" }, },
            TopRightRed = Input { Value = 1, },
         },
         ViewInfo = OperatorInfo { Pos = { 605, 82.5 } },
      },
      Saver1 = Saver {
         Inputs = {
            ProcessWhenBlendIs00 = Input { Value = 0, },
            Clip = Input {
               Value = Clip {
                  Length = 0,
                  Saving = true,
                  TrimIn = 0,
                  ExtendFirst = 0,
                  ExtendLast = 0,
                  Loop = 1,
                  AspectMode = 1,
                  Depth = 1,
                  TimeCode = 0,
                  GlobalStart = -2000000000,
                  GlobalEnd = 0
               },
            },
            OutputFormat = Input { Value = FuID { "TargaFormat" }, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Input = Input {
               SourceOp = "LensDistort1",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1100, 82.5 } },
         UserControls = ordered() {
            MakeLoader = {
               BTNCS_Execute = "                  comp:Lock()\n                  flow = comp.CurrentFrame.FlowView\n                  posx, posy = flow:GetPos(tool)\n                  filepath = tool.Clip[1]\n                  myloader = comp:AddTool(\"Loader\", posx+1, posy - 1)\n                  myloader.Clip = filepath\n                  \n                  -- parse file name\n                  pathtable = eyeon.split(filepath, \"\\\\\")\n                  -- find last index of table\n                  k = 0\n                  for i in ipairs(pathtable) do\n                     k = i\n                  end\n                  filename = pathtable[k]\n                  j,k = string.find(filename, \"_v\")\n                  if k then\n                     l = string.find(filename, \"%.\", k+1)\n                     version = string.sub(filename, k, l-1)\n                     filename = string.sub(filename, 1, j-1)\n                                    \n                     myloader:SetAttrs({TOOLS_Name = version..\"_\"..filename, TOOLB_NameSet = true})\n                  end\n                  comp:Unlock()\n               ",
               ICS_ControlPage = "File",
               INPID_InputControl = "ButtonControl",
               LINKS_Name = "Make Loader"
            }
         }
      }
   }
}


Not sure if I set up the ramps in the right direction there.
Bryan Ray
http://www.bryanray.name
http://www.musevfx.com
Offline

trackster

  • Posts: 5
  • Joined: Sun Feb 25, 2018 1:36 am
  • Real Name: Matt Ralph

Re: Lens Distortion STMap

PostTue Apr 10, 2018 8:32 pm

Bryan... THANK YOU!
I'm trying this out... this is the closest I've been able to get to ever making it work properly. YOU ARE AMAZING.

A few things (keep in mind I'm extremely new to fusion)
1. I changed all my settings to 32 bit float and no compression and it seems like it's doing a pretty good job as an STMap in Nuke. Are there any settings I should add to ensure that I'm not losing any info in my exr?
2. If I apply it directly to my image it ends up flipping everything vertically (you mentioned this might happen in your note). How can I fix this?
3. I'll have to play around with cropping to ensure I'm not losing anything on the edges I think. Right now in the extreme corners the STmap undistort does not quite match the raw export from 3DE. It's close, but not perfect. A few pixels off. Maybe has something to do with the values or variables in the lensdistort node not quite matching?

Anyway, thank you again! You're a rockstar.

m
Offline
User avatar

Bryan Ray

  • Posts: 661
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Lens Distortion STMap

PostWed Apr 11, 2018 2:33 pm

trackster wrote:1. I changed all my settings to 32 bit float and no compression and it seems like it's doing a pretty good job as an STMap in Nuke. Are there any settings I should add to ensure that I'm not losing any info in my exr?


That should cover it. If you didn't already, you should set the depth on the Backgrounds to at least half float.

2. If I apply it directly to my image it ends up flipping everything vertically (you mentioned this might happen in your note). How can I fix this?


In the Background node that makes the T channel(green), just swap the colors in the gradient.

3. I'll have to play around with cropping to ensure I'm not losing anything on the edges I think. Right now in the extreme corners the STmap undistort does not quite match the raw export from 3DE. It's close, but not perfect. A few pixels off. Maybe has something to do with the values or variables in the lensdistort node not quite matching?


Yes, you'll want a Crop to match the undistorted dimensions you get from 3DE. The Backgrounds' dimensions should match your original frame. I seem to recall that there was an error of some kind in Fusion's handling of 3DE data at some point. I thought it had been fixed, but I'm not certain.
Bryan Ray
http://www.bryanray.name
http://www.musevfx.com
Offline

trackster

  • Posts: 5
  • Joined: Sun Feb 25, 2018 1:36 am
  • Real Name: Matt Ralph

Re: Lens Distortion STMap

PostThu Apr 12, 2018 7:33 pm

Thanks again!
Yes, I've discovered that the distortion that Fusion provides vs the distortion that Nuke provides with exactly the same values inputted into their respective lensDistort nodes does yield slightly different results. They're close, but not exact.
That's a big problem as it means the distortion coming out of Fusion is wrong, even though the numbers going in are right (assuming I've done everything else correctly).

I'm not sure how to continue at this point. If it is indeed a Fusion problem I guess that means I'll have to wait until it gets fixed.
Offline

Chad Capeland

  • Posts: 1711
  • Joined: Mon Nov 10, 2014 9:40 pm

Re: Lens Distortion STMap

PostThu Apr 12, 2018 7:48 pm

trackster wrote: That's a big problem as it means the distortion coming out of Fusion is wrong, even though the numbers going in are right (assuming I've done everything else correctly).


Are you unit testing or black box testing?
Chad Capeland
Indicated, LLC
www.floweffects.com
Offline

trackster

  • Posts: 5
  • Joined: Sun Feb 25, 2018 1:36 am
  • Real Name: Matt Ralph

Re: Lens Distortion STMap

PostThu Apr 12, 2018 7:53 pm

I'm not sure what that means, haha.
I'm testing the values across a few different shots on different shows here. If I use the same values to write out undistorted plates, for instance, with one coming out of Nuke (using Nuke's LensDistort node and 3DEqualizer's distortion values) and one coming out of Fusion (using Fusion's LensDistort node and 3DEqualizer's distortion values), and then directly compare them switching from A to B, the distortion visually looks different.

Return to Fusion

Who is online

Users browsing this forum: No registered users and 5 guests