Skip to content

Commit 1242c29

Browse files
committed
better underflowing fix
1 parent d8c2ac3 commit 1242c29

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

FatToni/FilterFatToni.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,15 @@ void FILTERNAME::runLayer(const ImageSettings &options, const PipeSettings &set
231231
//--------------------------------
232232

233233
//actuall toning phase, blend between overlay and mix, overlay is a hard version, mix a soft one
234-
rgb.r = BLEND ( OVERLAY( toning.r ,rgb.r), MIX( toning.r ,rgb.r), optCont);
235-
rgb.g = BLEND ( OVERLAY( toning.g ,rgb.g), MIX( toning.g ,rgb.g), optCont);
236-
rgb.b = BLEND ( OVERLAY( toning.b ,rgb.b), MIX( toning.b ,rgb.b), optCont);
234+
rgb.r = BLEND ( OVERLAY( toning.r ,rgb.r), clipf(MIX( toning.r ,rgb.r),0.f,1.f), optCont); //clip to avoid underflowing!
235+
rgb.g = BLEND ( OVERLAY( toning.g ,rgb.g), clipf(MIX( toning.g ,rgb.g),0.f,1.f), optCont);
236+
rgb.b = BLEND ( OVERLAY( toning.b ,rgb.b), clipf(MIX( toning.b ,rgb.b),0.f,1.f), optCont);
237237

238238
//Multiply with the base color
239239
rgb.r = MULTIPLY(basergb.r, rgb.r);
240240
rgb.g = MULTIPLY(basergb.g, rgb.g);
241241
rgb.b = MULTIPLY(basergb.b, rgb.b);
242-
243-
rgb.r = clipf(rgb.r,0.f,1.f);
244-
rgb.g = clipf(rgb.g,0.f,1.f);
245-
rgb.b = clipf(rgb.b,0.f,1.f);
242+
246243

247244
//Back to float and degamma
248245
iR = FTOI16(rgb.r*rgb.r);

0 commit comments

Comments
 (0)