Log in

View Full Version : Can AviSynth replicate this effect?


orion44
4th February 2025, 18:44
How do I create this effect with AviSynth?

Effect demonstrated @ 2:16

https://www.youtube.com/watch?v=H5GD-g-aniI

SaurusX
8th February 2025, 15:11
It reminds me of the effect from this thread: https://forum.doom9.org/showthread.php?t=173030

Something like this is a close approximation:

generalconvolution(0,"0 1 0 1 0 1 0 1 0",chroma=false,luma=true)
generalconvolution(0,"0 1 0 1 0 1 0 1 0",chroma=false,luma=true)
sharpen(.5)

Selur
8th February 2025, 15:58
I thought about https://forum.doom9.org/showthread.php?t=108814 when looking at the video,...

wonkey_monkey
9th February 2025, 01:02
Judging by the description of the filter and the example in the video at 2:16, is it not simply a blur overlaid at (e.g.) 50% weight?

https://i.imgur.com/kQ6U4Z7.png

Left side: unfiltered side of video with a 4px Gaussian blur overlaid at 50%
Right side: physical filter from the video

Only problem is it'll dull highlights (see eye glints), and that's tricky to resolve if they're already at peak white.

Didée
9th February 2025, 10:16
Try to "softlight-filter" the source with a blurred source.

https://thumbs4.imagebam.com/41/15/b7/MEZJ0LF_t.jpg (https://www.imagebam.com/view/MEZJ0LF) https://thumbs4.imagebam.com/d3/e4/d2/MEZJ0LI_t.jpg (https://www.imagebam.com/view/MEZJ0LI) https://thumbs4.imagebam.com/8c/55/43/MEZJ0LK_t.jpg (https://www.imagebam.com/view/MEZJ0LK)

orion44
10th February 2025, 00:44
Try to "softlight-filter" the source with a blurred source.

https://thumbs4.imagebam.com/41/15/b7/MEZJ0LF_t.jpg (https://www.imagebam.com/view/MEZJ0LF) https://thumbs4.imagebam.com/d3/e4/d2/MEZJ0LI_t.jpg (https://www.imagebam.com/view/MEZJ0LI) https://thumbs4.imagebam.com/8c/55/43/MEZJ0LK_t.jpg (https://www.imagebam.com/view/MEZJ0LK)

Wow. This looks amazing.

You're a genius.

Thank you!

Didée
10th February 2025, 02:43
Oh, the filenames have been lost by the hoster, thus misses information.

The blur level was gaussian with radius 4, the blend operation was softlight 25% on the 1st pic, 50% on the 2nd.

real.finder
10th February 2025, 08:45
Wow. This looks amazing.

You're a genius.

Thank you!

indeed, he is Didée we know and love :D
Oh, the filenames have been lost by the hoster, thus misses information.

The blur level was gaussian with radius 4, the blend operation was softlight 25% on the 1st pic, 50% on the 2nd.

maybe it's better to post the avs script :)

Didée
10th February 2025, 19:07
What avs script? :confused: - It just took a few seconds to make it with my image processing app (neither Photoshop nor Gimp, here it is "Picture Window"). :D

A good (xy) LUT for softlight is "1 y 255 / 2 * - x 255 / * x 255 / * 2 y 255 / * x 255 / * + 255 *" (this is not the Photoshop formula, but the better "Pegtop" one, thanks Wikipedia: (1-2b)a²+2ba) ).
But the operation really must be done internally in RGB space, YUV or just Y is not good.

If I only knew how to set up an avs function, it's been so long since ... :scared:
There's already an idea: since Softlight (and Hardlight same) are generically centered around luminosity 50%, methinks there should be a gamma modifier for the (blurred) b-clip, so you can adapt to "rather bright" or "rather dark" input footage.

Didée
11th February 2025, 20:05
Okay then, my first function since more than a decade ago. :o

As told before:
- Softlight with a blurred overlay (or alternatively, don't blur the overlay with radius=0.0)
- adjust strength of the effect ("amount")
- possibility to steer the effect (a little) with "gamma" for very dark or very bright input
all squeezed into a single lut, to minimize rounding errors by chaining of discrete steps, since this thingy is only 8-bit anyway

dependencies: mt_masktools.dll, fastblur.dll (https://forum.doom9.org/showthread.php?t=176564)

I've no idea what a good default for "radius" is, but you'll play with the values anyway.

Oh, and ... no matter what the input is, it gets converted to RGB32 and comes out as RGB32. :p


# LoadPlugin("wherever\mt_masktools-26.dll")
# LoadPlugin("wherever\fastblur.dll")


function CineGlow(clip c, float "amount", float "radius", float "gamma", string "cmatrix")
{
amount = default(amount, 0.5) # how much of the softlight-effect to apply, usually 0.0 - 1.0, >1.0 is possible
radius = default(radius, 8.0) # radius of the gauss-blur that is overlayed. radius=0.0 collapses mt_lutxy to mt_lut
gamma = default(gamma, 1.0) # gamma adjust of the overlay clip. Try <1.0 if input is very bright, or >1.0 if input is very dark
cmatrix= default(cmatrix, "Rec.709") # ColorMatrix, depending on you input. If it's YUV, most probably it's Rec.709, but perhaps it's something else. For RGB input it doesn't matter.

AMNTX = string(1.0-amount)
AMNTY = string(amount)
GAMM = string(1.0/gamma)

base = c.converttoRGB32(matrix=cmatrix)
blurr = base.fastblur(radius,gamma=false)

Red = base.showRed("YV12")
Green = base.showGreen("YV12")
Blue = base.showBlue("YV12")
RedB = blurr.showRed("YV12")
GreenB= blurr.showGreen("YV12")
BlueB = blurr.showBlue("YV12")

LUT_expr = "x "+AMNTX+" * 1 y 255 / "+GAMM+" ^ 2 * - x 255 / * x 255 / * 2 y 255 / "+GAMM+" ^ * x 255 / * + 255 * "+AMNTY+" * +" # overlay gets blurred, normal
LUT_expr2 = "x "+AMNTX+" * 1 x 255 / "+GAMM+" ^ 2 * - x 255 / * x 255 / * 2 x 255 / "+GAMM+" ^ * x 255 / * + 255 * "+AMNTY+" * +" # overlay is not blurred, ugly

softlightRed1 = Red .mt_lutxy(RedB, LUT_expr, U=1,V=1)
softlightGreen1 = Green.mt_lutxy(GreenB,LUT_expr, U=1,V=1)
softlightBlue1 = Blue .mt_lutxy(BlueB, LUT_expr, U=1,V=1)

softlightRed2 = Red .mt_lut(LUT_expr2, U=1,V=1)
softlightGreen2 = Green.mt_lut(LUT_expr2, U=1,V=1)
softlightBlue2 = Blue .mt_lut(LUT_expr2, U=1,V=1)

softlightRGB = radius==0.0 ? mergeRGB(softlightRed2,softlightGreen2,softlightBlue2)
\ : mergeRGB(softlightRed1,softlightGreen1,softlightBlue1)

softlightRGB
return(last)
}

Some quick impressions.

Darkish image (where this all started):

Source -vs- CineGlow default -vs CineGlow /w gamma
https://thumbs4.imagebam.com/23/14/fd/MEZKSJ9_t.png (https://www.imagebam.com/view/MEZKSJ9) https://thumbs4.imagebam.com/34/9e/22/MEZKSJA_t.png (https://www.imagebam.com/view/MEZKSJA) https://thumbs4.imagebam.com/a6/b8/8f/MEZKSJD_t.png (https://www.imagebam.com/view/MEZKSJD)


A too bright image (no, that model wasn't folded by me, I'm not yet finished with this one)

Source -vs- CineGlow default -vs CineGlow /w gamma
https://thumbs4.imagebam.com/32/2a/e5/MEZKSJH_t.png (https://www.imagebam.com/view/MEZKSJH) https://thumbs4.imagebam.com/9f/ee/44/MEZKSJK_t.png (https://www.imagebam.com/view/MEZKSJK) https://thumbs4.imagebam.com/a0/c8/e0/MEZKSJN_t.png (https://www.imagebam.com/view/MEZKSJN) / https://thumbs4.imagebam.com/26/80/a0/MEZKWYF_t.png (https://www.imagebam.com/view/MEZKWYF)


edit:
- added "matrix" parameter for YUV >> RGB conversion
- added a slightly less aggressive variant for the "too bright" source with gamma

wonkey_monkey
11th February 2025, 20:33
Can the ShowRed/ShowGreen etc be changed to ...("Y8")? It seems like U and V aren't used.

Didée
11th February 2025, 21:07
Quite possible, I dunno. My (avisynth) technical progress stopped 10~15 years ago ... I'm not sure what colorspaces MaskTools can handle, at least my latest version, would need to watch out if there's something newer than I'm using. Feel free to improve! :)
Also this seems like a function where rgba_rpn/y8_rpn could come to good use ... is this one using LUTs (fast), or is it computing on-the-fly (probably slower)?

Bit more seriously, there should be a "matrix" parameter for the converttoRGB32. If input is YV12, it'll most probably be Rec.709, but if it's something else, one should have the possibility to make a correct conversio.

real.finder
11th February 2025, 21:13
Okay then, my first function since more than a decade ago. :o

As told before:
- Softlight with a blurred overlay (or alternatively, don't blur the overlay with radius=0.0)
- adjust strength of the effect ("amount")
- possibility to steer the effect (a little) with "gamma" for very dark or very bright input
all squeezed into a single lut, to minimize rounding errors by chaining of discrete steps, since this thingy is only 8-bit anyway

dependencies: mt_masktools.dll, fastblur.dll (https://forum.doom9.org/showthread.php?t=176564)

I've no idea what a good default for "radius" is, but you'll play with the values anyway.

Oh, and ... no matter what the input is, it gets converted to RGB32 and comes out as RGB32. :p


# LoadPlugin("wherever\mt_masktools-26.dll")
# LoadPlugin("wherever\fastblur.dll")


function CineGlow(clip c, float "amount", float "radius", float "gamma")
{
amount = default(amount, 0.5) # how much of the softlight-effect to apply, usually 0.0 - 1.0, >1.0 is possible
radius = default(radius, 8.0) # radius of the gauss-blur that is softlighting. radius=0.0 collapses mt_lutxy to mt_lut
gamma = default(gamma, 1.0) # gamma adjust of the softlighting clip. Try <1.0 if input is very bright, or >1.0 if input is very dark

AMNTX = string(1.0-amount)
AMNTY = string(amount)
GAMM = string(1.0/gamma)

base = c.converttoRGB32()
blurr = base.fastblur(radius)

Red = base.showRed("YV12")
Green = base.showGreen("YV12")
Blue = base.showBlue("YV12")
RedB = blurr.showRed("YV12")
GreenB= blurr.showGreen("YV12")
BlueB = blurr.showBlue("YV12")

LUT_expr = "x "+AMNTX+" * 1 y 255 / "+GAMM+" ^ 2 * - x 255 / * x 255 / * 2 y 255 / "+GAMM+" ^ * x 255 / * + 255 * "+AMNTY+" * +" # overlay gets blurred, normal
LUT_expr2 = "x "+AMNTX+" * 1 x 255 / "+GAMM+" ^ 2 * - x 255 / * x 255 / * 2 x 255 / "+GAMM+" ^ * x 255 / * + 255 * "+AMNTY+" * +" # overlay is not blurred, ugly

softlightRed1 = Red .mt_lutxy(RedB, LUT_expr, U=1,V=1)
softlightGreen1 = Green.mt_lutxy(GreenB,LUT_expr, U=1,V=1)
softlightBlue1 = Blue .mt_lutxy(BlueB, LUT_expr, U=1,V=1)

softlightRed2 = Red .mt_lut(LUT_expr2, U=1,V=1)
softlightGreen2 = Green.mt_lut(LUT_expr2, U=1,V=1)
softlightBlue2 = Blue .mt_lut(LUT_expr2, U=1,V=1)

softlightRGB = radius==0.0 ? mergeRGB(softlightRed2,softlightGreen2,softlightBlue2)
\ : mergeRGB(softlightRed1,softlightGreen1,softlightBlue1)

softlightRGB
return(last)
}

Impressions.

Darkish image (where this all started):

Source -vs- CineGlow default -vs CineGlow /w gamma
https://thumbs4.imagebam.com/23/14/fd/MEZKSJ9_t.png (https://www.imagebam.com/view/MEZKSJ9) https://thumbs4.imagebam.com/34/9e/22/MEZKSJA_t.png (https://www.imagebam.com/view/MEZKSJA) https://thumbs4.imagebam.com/a6/b8/8f/MEZKSJD_t.png (https://www.imagebam.com/view/MEZKSJD)


A too bright image (no, that model wasn't folded by me, I'm not yet finished with this one)

Source -vs- CineGlow default -vs CineGlow /w gamma
https://thumbs4.imagebam.com/32/2a/e5/MEZKSJH_t.png (https://www.imagebam.com/view/MEZKSJH) https://thumbs4.imagebam.com/9f/ee/44/MEZKSJK_t.png (https://www.imagebam.com/view/MEZKSJK) https://thumbs4.imagebam.com/a0/c8/e0/MEZKSJN_t.png (https://www.imagebam.com/view/MEZKSJN)

WOW! you really didn't follow the news of avs/avs+ since decade :eek:

first, mt_masktools-26.dll is so old there are https://github.com/pinterf/masktools/releases , and showRed and others can be replaced with ExtractR and so in avs+, converttoRGB32 with ConvertToPlanarRGB

but anyway, thanks you for sharing the script :) I didn't know you didn't use avs but this is what the OP ask for! :confused: "Can AviSynth replicate this effect?" in "Avisynth Usage"

wonkey_monkey
11th February 2025, 22:02
Expr is generally faster than my filter (and its rewrite) for simple cases like this; I tested it and it was slightly slower than mt_lut/mt_lutxy.

orion44
12th February 2025, 14:17
WOW! you really didn't follow the news of avs/avs+ since decade :eek:

first, mt_masktools-26.dll is so old there are https://github.com/pinterf/masktools/releases , and showRed and others can be replaced with ExtractR and so in avs+, converttoRGB32 with ConvertToPlanarRGB

but anyway, thanks you for sharing the script :) I didn't know you didn't use avs but this is what the OP ask for! :confused: "Can AviSynth replicate this effect?" in "Avisynth Usage"

I avoid using any AviSynth filters modified by pinterf and just use the good old versions by the original authors.

There's something 'off' with avs+ and updated filters post-2015, which makes those amazing scripts from the 2000s look worse (less visually pleasing/authentic).

real.finder
12th February 2025, 15:51
I avoid using any AviSynth filters modified by pinterf and just use the good old versions by the original authors.

There's something 'off' with avs+ and updated filters post-2015, which makes those amazing scripts from the 2000s look worse.

do you have any proof? for me and most people here they work fine so far, also pinterf is not the only one nor the 1st one updating plugins, see here https://forum.doom9.org/showthread.php?t=169832 also there are https://github.com/Asd-g?tab=repositories so your clam mean almost all those and asv+ users are wrong and the only one right is you, maybe you get some bug that only showed in some rare case so you need to show us what is the "'off' with avs+ and updated filters post-2015"

Emulgator
12th February 2025, 21:47
orion44, it might have to do with frame properties.
Some more updated filters expect them now and they can not be assumed to be correct everywhere in the chain.
Takes manual fiddling, I had that here with the various versions of QTGMC and other stuff (feisty2's) too.

real.finder
22nd February 2025, 00:35
orion44, it might have to do with frame properties.
Some more updated filters expect them now and they can not be assumed to be correct everywhere in the chain.
Takes manual fiddling, I had that here with the various versions of QTGMC and other stuff (feisty2's) too.

if that the case, then he can use propClearAll() after the video source call

FranceBB
24th February 2025, 13:31
it might have to do with frame properties.

Ah, frame properties, my recurring enemy in this never ending battle...!

if that the case, then he can use propClearAll() after the video source call

yeah propClearAll() helps in most cases, however if I'm not going to x262/x264/x265 but to something else (like AppleProRes using the Lavc encoder in FFMpeg etc) I then have to remember to populate them at the end, which is always a bit of a pain...

real.finder
25th February 2025, 05:00
however if I'm not going to x262/x264/x265 but to something else (like AppleProRes using the Lavc encoder in FFMpeg etc) I then have to remember to populate them at the end, which is always a bit of a pain...

I think that another story, he need to make it like 2.6 which dont has frame properties at all

FranceBB
25th February 2025, 23:50
I think that another story, he need to make it like 2.6 which dont has frame properties at all

yeah yeah for his use case PropClearAll() is gonna work, I was just documenting my pain in my daily battles against frame properties...

https://media.tenor.com/hJj59qgMAeYAAAAM/emoji-crying.gif