A Softness far past the range (an expression can set one) overflowed
the padding's u32 before drop_shadow_pad saturated it; the new test
panicked there in a debug build and renders a finite shadow now. The
GPU test's comment and the parity row now say that a cut margin renders
on the CPU, and the CPU test quotes the measured 0.11 at Softness 8000.
Drop Shadow pads its buffer by Distance + 1.5 x Softness, but the pixel
budget (#2261) cuts that margin for a large Softness: from about 870 on
a 1080p layer. The box passes then dropped what they spread past the
edge, so the shadow came out too faint: at the centre of a 64 x 48
layer, 0.11 of the Gaussian at Softness 8000. With a cut margin the CPU now blurs as
if the buffer went on with transparency (the Gaussian is unchanged,
sigma = Softness / 2). The GPU hands that case to the CPU and keeps
every margin that fits, so those results are unchanged.
Measured on an M-series Mac: 1080p at Softness 30000 takes 0.10 s, and
a 4096 x 4096 layer (an 8192 x 8192 buffer) takes 0.99 s on the CPU.
The pad is computed once for both paths (drop_shadow_pad) and saturates
instead of overflowing on a huge Softness.
The spin helper's name gives its unit (degrees), the zoom helper's doc
uses |amount| as the code does, and the parity row and tests say what
is and is not checked against After Effects.
Expressions are not clamped to the hard range. Padding computed
amount.abs().ceil() as u32 + 1, which overflowed (a panic in debug builds)
from about 4.3e9 on both the CPU and GPU paths, a NaN Amount filled the
layer with NaN, and an infinite one sent infinite coordinates to the
samplers' integer pixel positions.
turbulent_amount_px, shared by both paths, skips a zero or NaN Amount and
bounds the rest to 2^24 px. Values inside the hard range are unchanged.
Tests cover both ends of the range with every displacement kind, pinning
and Resize Layer (finite, padding within budget), Amounts past it, and
CPU/GPU agreement at -10000, 10000 and infinity.
After Effects records Sub Scaling's valid range as 10..10000 (slider
25..100), but the hard range stopped at 100, so prop.set and the value
editors clamped 200 to 100. The CPU renderer and the GPU pointwise path
also capped the ratio at 1, so a value above 100 rendered as 100 even
once stored.
Widen the hard range for Fractal and Turbulent Noise (they share the
parameter; slider and default unchanged) and take the ratio from one
sub_scaling_ratio (0.1..100) on the CPU and both GPU paths. Above 100
each octave is larger than the last.
Tests: the range and that 200 and 10000 render differently from 100;
finite output at both ends with Complexity 20, Perspective Offset,
Turbulence Factor 10 and a huge offset; CPU/GPU parity at 200 and 10000
on the pointwise and fxn_fractal paths; prop.set, undo/redo and
save/reopen keep 10 and 10000 (engine range table). The .aep range
guard no longer lists the parameter.
Zoom spreads its 32 samples over scales 1 ± Amount / 200 about the
centre. Past Amount 200, which the range now allows, that reaches below
0 and samples the layer mirrored through the centre: at 1000 a layer
white on the left and black on the right turned the right half 35 %
grey.
raster::radial_blur_zoom_scale keeps the old scales up to 200 exactly
and spreads the samples evenly from the centre to 1 + Amount / 200
beyond. The CPU and GPU paths both take their samples from it. Work per
pixel stays at 32 samples at any Amount.
Each octave's frequency and Perspective Offset depth are Sub Scaling to
the power of the octave. Above 100 % (After Effects allows 10000) that
reaches 100^±19 at Complexity 20, and Perspective Offset or Turbulence
Factor times the offset overflowed to infinity and drew NaN.
Both stay within 1e20 and its inverse and remain each other's inverse,
so an octave's offset in lattice cells is unchanged; 10..100 never
reaches the bound. The scaled offset stays within 1e36 px, past where
the lattice index saturates. The CPU, fxn_fractal (from fractal_gpu)
and pointwise paths share the bound; one octave_origin replaces the two
copies of the origin code.
After Effects records Blurriness as valid from 0 to 30000; the hard range
was 0..3000, so prop.set and the value editors clamped 4000 to 3000. The
default (0) and the 0..50 slider stay as they were. Padding stays within
the effect pixel budget at the new maximum, on the CPU and the GPU.
Tests: the engine round trip (prop.set, undo/redo, save/reopen, older
projects) gets a row, the aep guard drops its known-narrower row, and the
CPU and GPU render at 30000 is checked bounded, finite and matching.
Each box-pass thread started its running sum by reading all 2r+1 pixels
of its window, even past the end of the line. At Gaussian Blur's
Blurriness 30000 the radius is about 15000 px, so most of those reads were
the same edge pixel or zero. Sum the pixels inside the line once and add
the repeated edges times their count, as the CPU pass does.
Apple M5 (Metal), 4096 x 4096, three passes per axis, repeated edges:
r = 15000 went from about 185 ms to 75 ms; r = 1500 is unchanged (80 ms).
At the top of the new range the CPU render stays linear in Amount
(colour moves Amount / 50 of its difference from the blur) and finite on
32 bpc over-range input, and the GPU matches the CPU at 8 and 32 bpc.
Below -100 % an Expansion edge crosses the opposite one and the source
rectangle flips. Pin that geometry, check that the extremes (including
a zero-size source and Unstretch) keep the buffer size and render
finite pixels, and compare CPU and GPU at the new minimum.
## Behavior
A new Cineon Converter opens with Gamma 1.7. Its Version parameter is 2 by default. A converter saved before Version existed opens as version 1, retaining its Gamma value, keyframes, and expression text and rendering on its original scale. Reset keeps the instance's Version.
In version 2:
- Log to Linear raises the exposure to `1 / gamma` before subtracting the black offset and normalizing: `(E^(1/g) - O^(1/g)) / (1 - O^(1/g))`, with `E = 10^((code - white) * 0.002 / 0.6)` and `O` the exposure at the black point. Gamma 1 gives linear output, and a larger Gamma lightens the midtones. Highlight Rolloff then applies as before, and Linear to Log is the inverse.
- Log to Log returns code values unchanged at Gamma 1 and raises the normalized code value to `1 / gamma` at other values. With custom black or white points, the code values first go through the Gamma 1 conversion.
The CPU and GPU paths match. Version 1 instances render as before, and Interpret Footage ▸ Cineon Settings keeps its existing formula, which agrees with the version 2 Converter at Gamma 1.
The public Cineon Converter documentation (https://helpx.adobe.com/after-effects/using/utility-effects.html) describes Gamma as a midtone control and gives no defaults or formula. The default, the Log to Linear curve and the Log to Log behavior come from running and scripting After Effects 26.5 on my own machine and reading back the rendered pixels. In After Effects, choosing Log to Log also sets Gamma to 1 and Highlight Rolloff to 0; EffectCraft does not do that yet, because no command sets one parameter from another.
Animation preset format 3 records `cineonVersion` for a saved Gamma property and stores effect key times relative to the first key. Presets in formats 1 and 2 without that tag contain version 1 Gamma values; format 2 already has relative effect key times. Applying a whole old Cineon Converter also gives it version 1. Exposed Essential Properties Gamma values convert to the target converter version where their target is unambiguous (the conversion keeps the linear point; other Gamma values follow each version's own curve); enabled expressions on another scale are skipped instead of rewriting their source.
A saved Gamma records the Version its converter has at the current time. Applied to a converter whose Version is keyframed, a Gamma preset keeps those keys: the Gamma is converted to the one version they hold, or skipped when they hold several or an expression sets the Version. A preset that also holds the Version sets it from that property.
The project schema remains 2. `docs/architecture.md` describes the behavior above.
## Validation
Effect tests check version 2 Log to Linear at Gamma 1.7 (codes 95 to 685) and Gamma 2.2 (codes 180 to 620), and Log to Log at Gamma 1 (Rolloff 0 and 20) and Gamma 1.7, against the measured 8-bit values within one or two codes, plus round trips, version 1 rendering and the Interpret Footage agreement at Gamma 1. GPU tests compare the version 2 paths with the CPU. Engine tests cover old projects, Reset, presets, keyframes, and Essential Properties.
Commands run on `74d398c2`:
- `cargo fmt --all -- --check`
- `cargo clippy -p effectcraft-effects -p effectcraft-gpu -p effectcraft-project -p effectcraft-engine --all-targets -- -D warnings`
- `cargo test -p effectcraft-effects`: 546 passed (including `effects_doc_is_current`, so `docs/effects.md` needs no change), 1 ignored, plus 6
- `cargo test -p effectcraft-project`: 47 passed
- `cargo test -p effectcraft-gpu`: 253 passed, 1 ignored
- `cargo test -p effectcraft-engine`: 1,007 passed, 5 ignored, plus 27
WGSL's select evaluates both of its arguments, so the previous commit still
ran the overflowing pow and only discarded it. An explicit branch now skips
the power for a curve past the bound.
WGSL leaves the result of an overflowing pow indeterminate, so clamping
after it did not guarantee the CPU's 1e30 bound on every backend. A curve
past the bound (log2|t| / gamma > 99.7) now saturates to +-1e30 without
calling pow; between 1e30 and 2^99.7 the clamp gives the same 1e30, so the
GPU matches the CPU everywhere.
CPU / GPU comparisons at the new ends for Venetian Blinds (width 1, width
and feather 32000), Radial Wipe (feather 32000), Grid (border 2000),
Scatter (1000), Beam (4000), Change Color (1710 degrees) and Turbulent
Displace (seed 100000). The comparison counts infinity on both sides as
equal, so Levels (Individual Controls) gets a direct check that the GPU's
output is finite at the ends of its ranges. The Noise HLS test asserts the
spec's ranges, so it fails without them.
The 1e6 bound also capped curves that were finite before (gamma 0.1 on an
HDR value 4 x Input White is 4^10, about 1.05e6). The bound is now 1e30:
1e30 times the widest output range (2e4) is still finite, and every curve
below it renders as before. A test pins 4^10.
Hue, Lightness and Saturation go up to 1000 % and Grain Size down to 0 (it
keeps its wider maximum, 100), After Effects' recorded valid ranges in the
same units. Noise HLS Auto shares the controls and widens with them.
Defaults and sliders are unchanged.
The renderers need no change: hue wraps, lightness and saturation clamp per
pixel after the noise is added, and Grain Size is floored at 0.1 px on the
CPU and the GPU, so the new values cost the same and stay finite.
The amounts were written as "percent" in keyframe text because their range
was 0..100, and Grain Size would become "percent" at 0..100; UNITS rows keep
the units they had.
Blend goes up to 10000 (it keeps its minimum of 1, below After Effects' 5)
and Jitter up to 500 %, After Effects' recorded valid ranges in the same
units. Defaults and sliders are unchanged.
The CPU and GPU renderers capped Jitter's dither at 100 %, so higher values
would be stored but render as 100. Both now take it from one function,
four_color_jitter, which keeps the dither linear up to 500 %. Blend 10000
is a finite softening (Blend squared) at the same cost.
Jitter was written as "percent" in keyframe text because its range was
0..100; a UNITS row keeps that unit.
Input/Output Black and White of every channel take -10000..10000 and Gamma
goes down to 0 (it keeps its wider maximum, 10), After Effects' recorded
valid ranges in the same units (the .aep mapping is Conv::Plain). Defaults
and the 0..1 / 0.1..3 sliders are unchanged.
Gamma 0 renders as the existing 0.01 floor, an exponent of 100, so an HDR
value a few times Input White would overflow f32 and an infinite curve
times an empty output range is NaN. The curve is now bounded at +-1e6 on
the CPU (Lv::apply) and the GPU (fxt_lv), so the output stays finite over
the whole range; values below the bound are unchanged.
The engine regression (tests/effect_ranges.rs) sets both ends of each row
through prop.set, checks undo/redo, save and reopen, and that a project
saved with the narrower ranges opens with the new ones and its values.
* Effects: cap Camera Lens Blur and median radii
Camera Lens Blur built its iris table (one row per pixel of radius) from an
uncapped Blur Radius before any size check, and the median window is filled
(2r + 1)^2 per row from an uncapped Radius, on the CPU and the GPU. The
radius is now capped where the work is built: 2000 buffer pixels for the
lens iris (UI max 500) and 512 for the median window (UI max 255), on both
paths.
* address review: cap camera lens reach with the spans
Reuse the existing diff() helper so a non-finite pixel fails the test
(f32::max ignored NaN). Keep exact equality on llvmpipe, which still
fails without the row-block fix; other adapters use the usual Bpc32
tolerance, because a 2e-6 bound can fail on unmeasured hardware and
does not catch the regression there.