Math: tileable noise, display gamma and explicit channel springs #7

Merged
ilusha merged 2 commits from Math into master 2026-10-27 23:46:16 +03:00
Collaborator

Base: master @ ab5e4bc. Two commits, 6 files, +282/−106, all authored by agent.

Tileable noise

Why: brushes need repeatable paper-grain and deckle textures without visible seams.

How: TileableNoise builds a seeded 256-entry permutation table (duplicated to 512) and evaluates 2D gradient noise. Cell coordinates wrap at the requested period, corner gradients are interpolated with a quintic fade, and the result is scaled into approximately [-1, 1]. fractal() sums weighted octaves, multiplying both sample frequency and period by two at each step, then normalizes by total weight so every octave remains tileable.

Tests cover periodicity, lattice zeros, bounds, seed variation, octave tiling and deterministic patterns.

Display gamma

Why: linear-light paint blending needs a small, shared conversion rather than duplicating gamma tables in brush code.

How: gammaToLinear() applies pow(encoded, 2.2) and linearToGamma() applies the inverse, both clamped to [0, 1]. Tests check reference values, round trips and clamping.

Springs

Why: animation must be driven by the caller's actual frame delta rather than a global clock, and the same spring implementation should work for scalar and compound values without duplicated logic.

How: SpringValue::step(deltaMs) integrates in substeps of at most 1 ms using stiffness and damping. Callers can set targets, snap, launch with initial velocity, choose parameters (including a critically damped response preset), and query settling using both position tolerance and a 16 ms velocity horizon. SpringChannels<N> applies the same stepping to SpringVec2, SpringRect and SpringColor.

Verification

Success: 6 tests passed.

A separate smoke program exercised scalar/vector/rect/colour springs, initial launch, substepping and settling. CMakeLists.txt is unchanged: the port's MODULES_BUILD_TESTS gate does not exist on master.

**Base:** `master` @ `ab5e4bc`. Two commits, 6 files, +282/−106, all authored by `agent`. ## Tileable noise **Why:** brushes need repeatable paper-grain and deckle textures without visible seams. **How:** `TileableNoise` builds a seeded 256-entry permutation table (duplicated to 512) and evaluates 2D gradient noise. Cell coordinates wrap at the requested period, corner gradients are interpolated with a quintic fade, and the result is scaled into approximately `[-1, 1]`. `fractal()` sums weighted octaves, multiplying both sample frequency and period by two at each step, then normalizes by total weight so every octave remains tileable. Tests cover periodicity, lattice zeros, bounds, seed variation, octave tiling and deterministic patterns. ## Display gamma **Why:** linear-light paint blending needs a small, shared conversion rather than duplicating gamma tables in brush code. **How:** `gammaToLinear()` applies `pow(encoded, 2.2)` and `linearToGamma()` applies the inverse, both clamped to `[0, 1]`. Tests check reference values, round trips and clamping. ## Springs **Why:** animation must be driven by the caller's actual frame delta rather than a global clock, and the same spring implementation should work for scalar and compound values without duplicated logic. **How:** `SpringValue::step(deltaMs)` integrates in substeps of at most 1 ms using stiffness and damping. Callers can set targets, snap, launch with initial velocity, choose parameters (including a critically damped response preset), and query settling using both position tolerance and a 16 ms velocity horizon. `SpringChannels<N>` applies the same stepping to `SpringVec2`, `SpringRect` and `SpringColor`. ## Verification ``` Success: 6 tests passed. ``` A separate smoke program exercised scalar/vector/rect/colour springs, initial launch, substepping and settling. `CMakeLists.txt` is unchanged: the port's `MODULES_BUILD_TESTS` gate does not exist on master.
agent added 2 commits 2026-10-27 23:18:45 +03:00
TileableNoise builds a seeded permutation table and evaluates periodic 2D
gradient noise with quintic interpolation. Fractal noise sums weighted octaves,
increasing frequency and period together so the result tiles at every octave.

gammaToLinear and linearToGamma provide clamped gamma 2.2 conversion for
linear-light colour blending. Tests cover periodicity, bounds, seed variation,
octave tiling, reference values and round trips.
Math: make spring animation explicit and channel based
Some checks are pending
Windows / build (pull_request) Waiting to run
CMake on a single platform / build (pull_request) Waiting to run
CMake / build (pull_request) Waiting to run
4171ee1d02
SpringValue advances by a caller-supplied delta in substeps of at most 1 ms
instead of reading the global clock. It supports parameter sets, snapping,
launching with initial velocity and a settled test based on distance and
velocity.

SpringChannels applies the same implementation to scalars, vectors, rectangles
and colours, replacing the duplicated SpringVec and SpringRect paths.
requested review from ilusha 2026-10-27 23:18:46 +03:00
ilusha merged commit 865f085de9 into master 2026-10-27 23:46:16 +03:00
ilusha deleted branch Math 2026-10-27 23:46:17 +03:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: ilusha/Modules#7
No description provided.