Avisynth GrainFactory3

From wiki.selur.net
Jump to navigation Jump to search

GrainFactory3 adds film grain that depends on brightness: separate grain layers for dark, midtone and bright areas.

Filtering → Avisynth → Add Grain

GrainFactory3 controls in Hybrid
GrainFactory3 controls in Hybrid

What it does

Each of the three brightness ranges has its own grain strength, grain size, sharpness and texture. The layers are blended through luma masks, and the transition zones between the ranges can be moved. Negative strength makes grain with a deband-style generator instead of AddGrainC. An extra grain layer can be put on top of everything.

Typical uses:

  • Add natural-looking grain that is stronger in the shadows and weaker in the highlights.
  • Hide banding after heavy denoising.

The filter works on progressive material.

Settings

Control Parameter Range Hybrid default Meaning
Grain layers (dark / midtone / bright)
Luma Grain g1str / g2str / g3str −1000–1000 13 / 15 / 25 Luma grain strength. Positive values use AddGrainC; negative values use the deband-style generator.
Chroma Grain g1cstr / g2cstr / g3cstr −1000–1000 0 / 0 / 0 Chroma grain strength.
Sharpness g1shrp / g2shrp / g3shrp 0–100 60 / 66 / 80 Sharpness of the grain. Only available, and only effective, when the grain size is not 1.0.
Grain size g1size / g2size / g3size 0.5–4.0 1.5 / 1.2 / 0.9 Size of the grain.
Texture g1tex / g2tex / g3tex 0–100 0 / 0 / 0 Gives the grain a bump-like material look.
constant/dynamic g1const / g2const / g3const on/off off (dynamic) On: the same grain pattern in every frame. Off: new grain per frame.
Noise temp. averaging (%) temp_avg 0–100 0 Temporal averaging of the noise. No effect when all three layers are constant.
Brightness transitions
Dark→Midtone (start/end) th1 / th2 0–255 24 / 56 Luma range where dark grain fades into midtone grain.
Midtone→Bright (start/end) th3 / th4 0–255 128 / 160 Luma range where midtone grain fades into bright grain.
Average luma mask use_sAverageLumaMask on/off off Use an averaged luma mask for the blending.
Grain on top
Additional luma / chroma grain ontop_grain / ontop_cgrain −1000–1000 0 / 0 Extra grain over the whole picture.
constant/dynamic ontop_const on/off off (dynamic) Constant or dynamic extra grain.

Example

Default settings on a 10-bit YUV 4:2:0 source (no conversion is needed):

GrainFactory3mod()

How Hybrid calls it

  • The GrainFactory3mod script is loaded together with AddGrainC, RgTools, masktools2 and a deband plugin for the negative-strength grain.
  • Only parameters that differ from the defaults are written. The sharpness values are written only for layers whose size is not 1.0.
  • The script works on gray and planar YUV clips.
  • GrainFactory3 also offers the common options and can be added to the filter queue several times.

Background

  • GrainFactory3mod.avsi is based on "GrainFactoryLite" by 06_taro (v1.2, 2012), which is based on Didée's GrainFactory3. The 2020 mod adds high bit depth for AviSynth+.
  • Didée's original idea: make grain on a mid-grey base and merge it through a difference.
  • The VapourSynth version, Vapoursynth GrainFactory3, uses four brightness groups and has fewer options.

Sources

See also: Avisynth AddGrain