Page 1 of 1

Help with vector distortion maps

PostPosted: Sat Jul 31, 2021 8:19 pm
by mrbjjackson
Hi there,

I wonder if this effect I have in mind is possible:

I would like to use a custom shape as a distortion map. I want to make the image "bulge" in some areas and "shrink" in dark areas with other areas unaffected.

Essentially, similar to what the "Drip" node does, but instead of using their shape presets, using a custom shape of my choosing.

Is this kind of thing possible?

After some digging it seems like the "Vector Distortion" node is the tool I need but I can't find anywhere that explains how to generate the vector distortion maps.

Can you explain this to me please? Or point me in the direction of a resource that could help?

Thanks,
Ben

Re: Help with vector distortion maps

PostPosted: Sun Aug 01, 2021 1:12 am
by Bryan Ray
I think the Displace node is probably what you're after. The trick with it, though, is that you need a way to convert your shape into vectors that the displace will understand. For that, reach for the CreateBumpMap node. This will convert the luminance of a heightmap into an approximation of a normal map. Here's a walkthrough:

First, my source image and the result of the Drip node:

1.jpg
1.jpg (181.15 KiB) Viewed 2054 times


I've made a radial gradient using the Background tool and a Blur. I converted it to a normal map using CreateBumpMap:

2.jpg
2.jpg (63.18 KiB) Viewed 2054 times


Then I use a Displace node to approximate the result of the Drip:

3.jpg
3.jpg (179.1 KiB) Viewed 2054 times


Here are the nodes themselves so you can play with them and see how they work (though obviously you'll need to provide your own source image:

Code: Select all
{
   Tools = ordered() {
      Drip1 = Drip {
         Inputs = {
            Phase = Input { Value = -4.791, },
            Input = Input {
               SourceOp = "Loader1",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 500, 63.1212 } },
      },
      Loader1 = Loader {
         Clips = {
            Clip {
               ID = "Clip1",
               Filename = "P:\\continuing education\\Matchmoving\\352052c01_project\\01_buildings_bg.jpg",
               FormatID = "JpegFormat",
               StartFrame = -1,
               LengthSetManually = true,
               TrimIn = 0,
               TrimOut = 0,
               ExtendFirst = 0,
               ExtendLast = 0,
               Loop = 0,
               AspectMode = 0,
               Depth = 0,
               TimeCode = 0,
               GlobalStart = 0,
               GlobalEnd = 0
            }
         },
         Inputs = {
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
         },
         ViewInfo = OperatorInfo { Pos = { 390.667, 106.758 } },
      },
      Blur1 = Blur {
         Inputs = {
            Filter = Input { Value = FuID { "Fast Gaussian" }, },
            XBlurSize = Input { Value = 40.2, },
            Input = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 500.667, 139.758 } },
      },
      Background1 = Background {
         Inputs = {
            Width = Input { Value = 1024, },
            Height = Input { Value = 768, },
            Depth = Input { Value = 4, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Type = Input { Value = FuID { "Gradient" }, },
            GradientType = Input { Value = FuID { "Radial" }, },
            Start = Input { Value = { 0.5, 0.5 }, },
            End = Input { Value = { 0.551, 0.5 }, },
            Offset = Input { Value = -7.217, },
            Repeat = Input { Value = FuID { "Ping-Pong" }, },
         },
         ViewInfo = OperatorInfo { Pos = { 391.333, 140.97 } },
      },
      Displace1 = Displace {
         Inputs = {
            Offset = Input { Value = -0.5, },
            RefractionStrength = Input { Value = 1.56, },
            Input = Input {
               SourceOp = "Loader1",
               Source = "Output",
            },
            Foreground = Input {
               SourceOp = "CreateBumpMap1",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 636.667, 105.545 } },
      },
      CreateBumpMap1 = CreateBumpMap {
         CtrlWZoom = false,
         Inputs = {
            Input = Input {
               SourceOp = "Blur1",
               Source = "Output",
            },
            HeightScale = Input { Value = 33.07, },
         },
         ViewInfo = OperatorInfo { Pos = { 642, 140.364 } },
      }
   }
}


Make sure the Background, or your height map, has the same pixel dimensions as your source image for the most predictable results.

Displace also has a Light Power control that can give you that slight beveling appearance that you can see in the sky. I usually change Light Channel to Luminance to avoid hue shifts.