Page 1 of 1

Making a smoother Contrast Equation

Posted: 05 Dec 2023, 23:19
by Labont
Hey i'm making a Contrast effect and i'm using this equation : color.rgb = (color.rgb - 0.5) * Contrast + 0.5;. However, it's not really smooth and creates dark areas. Any idea of another smoother equation?

Re: Making a smoother Contrast Equation

Posted: 07 Dec 2023, 01:28
by ENBSeries
Maybe try non linear amount of shift, when near black and near white value is compressed. Something like the following code (check yourself for errors, i just give an idea):
float ContrastCurve = 1.0; //change this
float nonlinearcontrast = dot(color.rgb, 0.3333);
nonlinearcontrast = abs(nonlinearcontrast * 2.0 - 1.0);
nonlinearcontrast = saturate(1.0 - nonlinearcontrast);
nonlinearcontrast = pow(nonlinearcontrast, ContrastCurve);
color.rgb = (color.rgb - 0.5) * Contrast * nonlinearcontrast + 0.5;