ID 447058 - Lens Distortion node does not inverse correctly when bbox is set as automatic and as the output format

Follow

Problem summary
When using the LensDistortion node to undistort and then redistort using the inverse operation in a new node, the redistort operation does not match the original as expected.

The issue only occurs when the 'bbox' is set to 'auto' and the 'output format' is set to 'bbox' on both LensDistortion nodes.

This inconsistency causes issues as it is the only method to retain the overscan data at a new resolution for use in external programs.

Note: The 'bbox', 'output format' and 'distortion scaling' attributes only exist within Nuke 12.1v1 releases and later.

Customer reported version
nuke.12.2v2

Customer reported platform
windows10

Steps to reproduce

1) In a new Nuke session, Read in the footage to undistort.

2) Create a LensDistortion node, detect, then solve the result within the 'Analysis' tab

3) Within the 'LensDistortion' tab set the 'mode' to 'undistort' 
 
(At this point in time the plates would be rendered out to use as undistorted plates, worked on, then fed back into Nuke to re-apply the distortion)

4) Copy and paste the LensDistortion node below to create a new LensDistortion node

5) Within this new LensDistortion node, inverse the distort by setting the 'mode' to 'redistort'

6) Create a Reformat node under this LensDistortion node, setting it to 'none', then set the input format to the footage format and preserve the bounding box. (to crop and match to original)

7) Compare the results of the redistort to the original footage
Results: The footage result does not match the original when inversed.

Expected behaviour
When the undistort/redistort workflow uses the same values, the inverse should match

Actual behaviour
When the undistort/redistort workflow uses the same values, the inverse does not match and the result is warped.

Workaround
There are two possible workarounds to this issue:

1) Overscan resolution

Within the LensDistortion nodes, instead of using the 'bbox' as the 'output format', you can set a custom resolution that is greater than the original footage.

For example: Plus 100px seems to work if the original footage is 1920x1080, making the custom resolution 2020x1180. However, please note that the added value would need to increase if the original footage's resolution is larger.   

 

If this custom format is in both the 'output format' and the 'distortion scaling' for both nodes, this will inverse correctly.


2) STMap method

As an alternative for using the 'undistort' and 'redistort' within the LensDistortion node, you can set the 'mode' to 'STMap' to generate the distortion as an STMap.

Within an STMap the 'undistort' operation is held within the 'forward' channel and the 'redistort' is held within the 'backwards' channel. Using two STMap nodes in the same fashion as the LensDistortion nodes will not provide the correct inverse.

Note: There will be a slight mismatch in translation caused by the following related issue:
ID 467543 - Lens Distortion node does not inverse correctly when the lens center values are not 0 x 0 and the output format is set to BBox


Reproduced by support
This bug has been reproduced in:
Nuke 12.2v2 - Windows 10, MacOS 10.15.6, CentOS 7
Nuke 12.2v1 - Windows 10
Nuke 12.1v1 - Windows 10, MacOS 10.15.6, CentOS 7

Unable to reproduce bug in:
Nuke 12.0v7 - Windows 10, MacOS 10.15.6, CentOS 7

Earliest version tested
Nuke 12.1v1
- Prior to Nuke 12.1v1, the 'bbox', 'output format' and 'distortion scaling' attributes did not exist within the LensDistortion node.
 
Note
Write Test Harness tests to check for this

    We're sorry to hear that

    Please tell us why