Add a film grain effect

Grain is the third effect and the second that declares needsSources()
false, so it works as a filter stage in a cascade and can also lead one,
filling the canvas from a source the way blur does. Its knobs are the
amount a grain may push a pixel, the grain size in pixels, whether the
channels are drawn apart into coloured grain, and whether the response is
weighted towards the midtones — which it is by default, since film grains
least where it is least exposed. That last one means grain over an empty
canvas stays black unless the weighting is turned off.

Determinism comes from the same shape the scanlines effect uses: the
whole grain field is drawn serially from the Rng into one cell per grain
before any threading, and only the integer pixel arithmetic afterwards
runs under parallelFor.

The canvas fill blur used to keep to itself moves to
effects/source_fill.hpp unchanged, now that two effects want it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Si
2026-09-18 16:42:04 +02:00
co-authored by Claude Opus 5
parent b6b5f94f08
commit 82e730221e
7 changed files with 244 additions and 25 deletions
+1
View File
@@ -28,6 +28,7 @@ add_library(effector_core STATIC
src/core/registry.cpp
src/core/rng.cpp
src/effects/blur.cpp
src/effects/grain.cpp
src/effects/scanlines.cpp
)
target_include_directories(effector_core PUBLIC src)