0
\$\begingroup\$

I am trying to use UE's LensDistortion plugin (seems like it's bundled with the engine but only put to use in the Compositing sample project), and following the same workflow as the sample. Essentially, the idea is to create a camera model using the standard distortion parameters (radial, tangential etc.). The plugin then 'draws' a UV displacement map according to these params, and the original image is then distorted by adding these displacements to the corresponding pixels.

The level blueprint creates the displacement map and a material uses this to distort a given image (the distortion values are written only on the R and G channels, hence the mask in the material). Both are shown in these images:

enter image description here enter image description here

I don't understand the output I am getting. Seems to me the material function somehow ends up addressing invalid pixel values (less than 0 or greater than 1, assuming UV range is 0-1), so I see a strange 'repeating' of the image, as below:

enter image description here

The way the whole canvas is distorted makes sense spatially: but the pixel values corresponding to those locations are wrong. Am I doing something wrong in my material? How do I properly use this distortion plugin?

\$\endgroup\$
5
  • \$\begingroup\$ It looks like you've cranked the distortion parameters too high, so you're looking up a pixel too far over — so far that you wrap around to the other side of the buffer. Have you tried scaling down the amount of distortion you add to your UVs? \$\endgroup\$
    – DMGregory
    Feb 25, 2020 at 13:42
  • \$\begingroup\$ The parameters I put in approximately correspond to a GoPro lens, so I don't think it's too high. If the image spans the full canvas, I think the distortion makes sense - but perhaps the UV displacement computed by the node doesn't exactly match what the conventional distortion formula should output. \$\endgroup\$ Feb 25, 2020 at 19:40
  • \$\begingroup\$ Have you tried adjusting the Output Multiply parameter to a lower value? \$\endgroup\$
    – DMGregory
    Feb 25, 2020 at 19:48
  • \$\begingroup\$ Did you ever figure out the issue? I'm dealing with the same problem and scratching my head on it. \$\endgroup\$ Mar 19, 2020 at 4:46
  • \$\begingroup\$ Nope, I wrote my own postprocess material using the conventional distortion equations. I just noticed the answer below, I will try that. \$\endgroup\$ Mar 19, 2020 at 22:16

1 Answer 1

1
\$\begingroup\$

Firstly, you can run your Blueprint logic on EventBeginPlay, as I assume you won't be changing lens settings during game play.

Secondly set your Undistort Overscan Factor to 0.0 If you're going for a GoPro effect you won't need overscan area for undistorting down the road.

I have just tested this in 4.24, but my images are having issues uploading unfortunately.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .