ampas / aces-vwg-output-transforms

Other
0 stars 2 forks source link

Investigate collapse to black near white and black in directly invertible gamut compressor algorithm #19

Open KevinJW opened 1 year ago

KevinJW commented 1 year ago

During the meeting 8th February 2023 It was highlighted that some values near J of 0 and 100 and M also near 0 we were experiencing black output values.

this could be due to

KevinJW commented 1 year ago

refers to #6

priikone commented 1 year ago

I solved this in v030 by not letting the quadratic coefficient 'a' go smaller than 0.001.

priikone commented 1 year ago

While I was doing v032-pex prototype version I was playing with the gamut mapper's cusp-to-mid-blend and distance values, but I couldn't push the values where I wanted them because I was starting to get also NaNs from the gamut mapper. I traced it to the quadratic curve:

    float J0 = sqrt(b * b - 4 * a * c);           <------------- NaN
    float J1 = (-b - J0) / (2 * a);
          J0 = (-b + J0) / (2 * a);
    float projectJ = project_from.x < focusJ ? J0 : J1;

The subtraction inside the sqrt() goes negative and out comes NaN. The projectJ ends up being NaN.

KevinJW commented 1 year ago

we should try an alternate formation of the quadratic solve, here is a python gist I was looking at, with suitable scaling of the a parameter in the surrounding code we can probably use the normalised form.

KevinJW commented 1 year ago

I guess I should say the alternate is don't use a quadratic, but something else with a similar shape!

Kevin

nick-shaw commented 1 year ago

I’m not sure I consider it as “using a quadratic curve”. Rather the equation for the slope at a given J intersection has the form of a quadratic when combined with the JM value it needs to pass through, therefore the J intersect values for given JM are the roots of that quadratic.

priikone commented 1 year ago

Here's the M component as a plot. The input is the Dominant Wavelength ramp image. The ramp, in this case, goes from ACEScct 0 to 1.42.

M after chroma compression: CC_M

M after gamut mapping: GC_M

Notice how colorfulness strangely jumps higher as a result of gamut mapping at the top end. Some values come out as NaNs.