Skip to content

fix(core): sample hue curves across their periodic seam - #5287

Merged
jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/periodic-hue-curve-sampling
Oct 24, 2026
Merged

jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/periodic-hue-curve-sampling

Conversation

@user-github-me

Copy link
Copy Markdown
Contributor

Hue curves are compiled with samples at index / size, but the grading shader reads that periodic table at hue * (size - 1) and clamps the last sample. This shifts narrow hue adjustments and fails to interpolate back to the first sample across red. Real Chrome reproduces visible errors of 20 and 84 channel levels on a near-red source pixel.

Add a dedicated hue sampler that uses the periodic table size and wraps its upper sample. RGB curves keep their endpoint-inclusive, clamped sampler. The fix applies to all three hue-curve channels without changing authored grading data or lookup packing.

Validation:

  • Two real Chromium pixel regressions fail on upstream main; all four browser cases pass with the fix, including near-red interpolation and an RGB endpoint control. The test uses the actual grading runtime and WebGL shader.
  • All 100 related core grading/curve tests pass.
  • A separate probe of the rebuilt runtime verifies three grades across 11 source colors with no browser errors; affected pixels change to the periodic lookup result.
  • Core and CLI builds/typechecks, runtime contract checks, repository lint, formatting, test reachability, comment checks, and pre-commit checks pass.

The Chromium tests run when a local browser is available and follow the existing Windows opt-in convention.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed the mismatch on current main. compileHfHueCurve samples the periodic table at (index / size) * 360, but applyHueCurves still calls sampleAdvancedCurve(hsv.x, 1.0). That function scales by size - 1 and clamps the upper texel, so hue lookups drift and never interpolate from the last sample back to sample 0 across red. The new sampleHueCurve uses fract(coord) * size and wraps upper with mod, which matches the compile side, and RGB curves keep the endpoint-inclusive clamped sampler. The Chromium test runs the real shader against a CPU reference built from compileHfHueCurve, including near-red seam cases and an RGB endpoint control. main has since split the shader into HF_STAGE_* variants, but the hunk still applies cleanly inside #ifdef HF_STAGE_HUE_CURVES.

— Rames

@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 24, 2026
@jrusso1020
jrusso1020 removed this pull request from the merge queue due to a manual request Oct 24, 2026
@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 24, 2026
@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into heygen-com:main with commit 94a265e Oct 24, 2026
94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants