Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] Bug Reporting => [Max] Resolved Bugs => Topic started by: Juraj on 2016-10-18, 17:59:47

Title: LUT clamps the image
Post by: Juraj on 2016-10-18, 17:59:47
As title :- ). But unnecessary and not wanted. See illustration

VFB+ provides same look with same LUT, but doesn't clamp the image, retains full dynamic range for post-production ( including white-balance which required dynamic range to work properly).

[img height=1024 width=640 ]https://forum.corona-renderer.com/index.php?action=dlattach;topic=13515.0;attach=53554;image[/img]

Title: Re: LUT clamps the image
Post by: pokoy on 2016-10-18, 18:12:04
I thought LUTs would always clamp - great to see it's not the case, already looking forward to a fix.
Title: Re: LUT clamps the image
Post by: Ondra on 2016-10-18, 18:13:44
LUT is mapping from 0-1 to 0-1. So what happens over 1 is undefined - it is a tool of different trade (film). We can make values > 1 unaffected by LUT instead of clamping them, similar to contrast... if that is the desired solution
Title: Re: LUT clamps the image
Post by: Juraj on 2016-10-18, 18:27:00
Yup LUT remaps within 0-1, but it doesn't mean it must clip everything out of that range :- ). As you see it works perfectly and I used that workflow for whole year on many projects with VFB+.

I have to see what DavinciResolve or something similar does but those LogC files also have dynamic range that I believe are preserved when the whole file is shifted.
And I know some game engines are actually using dense LUTs to do tonemapping. Not even sure how that works but somehow it's possible.
Title: Re: LUT clamps the image
Post by: Ondra on 2016-10-18, 19:03:10
hmm... what about when LUT maps white (255 255 255) to RGB 0 127 256? What should happen in that case with overbrights, such as RGB 2.0 2.0 2.0?
Title: Re: LUT clamps the image
Post by: Juraj on 2016-10-18, 19:12:14
I honestly don't know straight out of head what happens, but it did work perfectly in all cases I had.

I'll try some theoretical scenarios, like one you mention, or applying LUT to fully over-blown render and taking it back to average exposure.

Edit: Photoshop clamps it. Vray doesn't bake LUT (neither plans on). Imho could depend on LUT, as you proposed, ignore above 1. If the LUT pushes value up, retain dynamic range by  ignoring it. If it lowers it than I guess it would clamp the whole range.
Title: Re: LUT clamps the image
Post by: Dionysios.TS on 2016-10-19, 12:46:29
Interesting stuff!
Title: Re: LUT clamps the image
Post by: pokoy on 2016-10-19, 13:48:11
hmm... what about when LUT maps white (255 255 255) to RGB 0 127 256? What should happen in that case with overbrights, such as RGB 2.0 2.0 2.0?

I guess it's too much to ask for extrapolating the expected values for values beyond 1, is this possible at all? I wonder how Rotem did handle overbrights for his VFB+.

Juraj, could you test with VFB+ what happens for values like rgb 2/2/2 with a LUT that visibly introduces a red or blue tint for example? Do values beyond 1 change accordingly or are they left untouched?
Title: Re: LUT clamps the image
Post by: Juraj on 2016-10-19, 13:56:45
I also toyed with some idea of shifting the values outside the range, basically how levels/curves would do. Because LUT can be holder of such information, but yeah, it can do also anything else.

Will try some when I get time, I mostly used LUTs that boost midtones and introduce a lot of contrast.
Title: Re: LUT clamps the image
Post by: Rotem on 2016-10-20, 07:47:39
VFB+ extrapolates for values outside of 0-1.
Title: Re: LUT clamps the image
Post by: pokoy on 2016-10-20, 16:24:06
VFB+ extrapolates for values outside of 0-1.
Thanks, Rotem. So, it's doable...
Title: Re: LUT clamps the image
Post by: Dionysios.TS on 2016-10-20, 16:45:34
Good to know! ;-)
Title: Re: LUT clamps the image
Post by: Ondra on 2016-10-21, 14:44:40
now when you say extrapolate, do you mean just going with 45deg slope in overbrights, just shifted by the last value in LUT, or going with the same slope as the last segment of LUT?
Title: Re: LUT clamps the image
Post by: pokoy on 2016-10-21, 15:26:07
now when you say extrapolate, do you mean just going with 45deg slope in overbrights, just shifted by the last value in LUT, or going with the same slope as the last segment of LUT?
I'm no expert by no means but maintaining the slope is probably the better approach.
Title: Re: LUT clamps the image
Post by: Juraj on 2016-10-21, 15:30:10
Curious for answer too but I guess the non-linear extrapolation could lead to some nuclear results :- )
Title: Re: LUT clamps the image
Post by: Rotem on 2016-10-21, 17:29:49
just going with 45deg slope in overbrights, just shifted by the last value in LUT

This. Though kind of hard to think of it that way since it's not a 1D LUT. I would imagine using the same slope as the last segment of the LUT would cause unintuitive effects if the slope is negative or very steeply positive.

Negative values are clamped to 0.0, there's no extrapolation for those.
Title: Re: LUT clamps the image
Post by: Ondra on 2016-11-15, 14:58:45
fixed
Title: Re: LUT clamps the image
Post by: Dionysios.TS on 2016-11-15, 16:41:53
You rock!