Log in

View Full Version : harmless linear light


feisty2
5th July 2015, 16:44
we all love linear light except that famous dark halo "effect", frigging little bummer
so I just, tried to slay linear light halos and got this
it's >= 87.5% linear and free of dark halos and got a closer result to pure linear light than simple sigmoidal space
I'll explain with a piece of vaporsynth USM script


import vapoursynth as vs
import Placebo as pb
core = vs.get_core()

clp = rule6

clp = core.fmtc.bitdepth(clp, fulls=False, fulld=True, bits=32, flt=True)
clp = core.fmtc.transfer(clp, transs="470bg", transd="linear", fulls=True, fulld=True)
# linear now #

msk = core.std.Expr (clp, "x 0.0625 < 1 0.0625 / x * x 1 0.0625 - > 1.0 x - 1 0.0625 / * 1.0 ? ?")
#blending weight of linear light and sigmoidal, pixels within 0.0625 - 0.9375 got a constant weight "1" (pure linear), pixels outta that range (= very dark/bright = in the "danger zone", and almost guaranteed to get you shit) got weights related to how dangerous they are (0.0 and 1.0 got a weight "0", weight grows to 1 linearly 'til 0.0625/0.9375)#

clps = pb.sigmoid_inverse_f (clp, cont=12)
difs = core.std.MakeDiff (clps, pb.gaussf (clps, 16))
clps = core.std.MergeDiff (clps, difs)
clps = pb.sigmoid_direct_f (clps, cont=12)
#filtering in sigmoidal space#

difl = core.std.MakeDiff (clp, pb.gaussf (clp, 16))
clpl = core.std.MergeDiff (clp, difl)
#filtering linearly#

clp = core.std.MaskedMerge(clps,clpl,msk)
#blend them now#

clp = core.fmtc.transfer(clp, transs="linear", transd="470bg", fulls=True, fulld=True)
clp.set_output ()
#back to gamma light#


Placebo.py https://github.com/IFeelBloated/VaporPlacebo/blob/master/Placebo.py#L6

you can use this method to do a better "almost gamma aware" sort of resizing also, just gotta resize the "msk" clp as well

FAQ:
Q: looks just like sigmoidal, why not just plain sigmoidal, will save all that extra work
A: yep, sigmoidal is partially linear like this, but that "partially linear" does not actually work linearly if any filter working like "neighbor/center" gets involved, say, the center pixel is actually at the linear part of the sigmoidal curve, and it should be filtered linearly, and those neighbor pixels around it might fall out of the linear part and the center pixel ends up, nonlinearly filtered, this method, is designed to solve the problem

pandy
6th July 2015, 07:43
In ancient times where CPU's was slow i use simple Invert() (negate) effect to counteract with gamma...