Add S-curve contrast to camera: more black, punchier highlights
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9fd19824ab
commit
fe3ef6366a
|
|
@ -25,12 +25,18 @@ function camHash(x: number, y: number, b: number): number {
|
|||
return ((x * 73856093) ^ (y * 19349663) ^ (bBits * 83492791)) >>> 0;
|
||||
}
|
||||
|
||||
// S-curve contrast: pushes darks to black, boosts brights
|
||||
function contrastCurve(b: number): number {
|
||||
return b < 0.5 ? 2 * b * b : 1 - 2 * (1 - b) * (1 - b);
|
||||
}
|
||||
|
||||
function brightnessToChar(b: number, x: number, y: number): string {
|
||||
if (b < 0.05) return " ";
|
||||
const h = camHash(x, y, b);
|
||||
if (b < 0.2) return CAM_DUST[h % CAM_DUST.length];
|
||||
if (b < 0.45) return CAM_LOW[h % CAM_LOW.length];
|
||||
if (b < 0.7) return CAM_MID[h % CAM_MID.length];
|
||||
const c = contrastCurve(b);
|
||||
if (c < 0.08) return " ";
|
||||
const h = camHash(x, y, c);
|
||||
if (c < 0.25) return CAM_DUST[h % CAM_DUST.length];
|
||||
if (c < 0.5) return CAM_LOW[h % CAM_LOW.length];
|
||||
if (c < 0.75) return CAM_MID[h % CAM_MID.length];
|
||||
return CAM_FULL[h % CAM_FULL.length];
|
||||
}
|
||||
|
||||
|
|
@ -40,8 +46,9 @@ function brightnessToColor(
|
|||
y: number,
|
||||
t: number
|
||||
): string {
|
||||
if (b < 0.05) return "";
|
||||
const clamped = Math.min(b, 1);
|
||||
const c = contrastCurve(b);
|
||||
if (c < 0.08) return "";
|
||||
const clamped = Math.min(c, 1);
|
||||
|
||||
// Slow-drifting phase creates shifting color bands across the frame
|
||||
const phase = Math.sin(x * 0.2 + y * 0.15 + t * 0.4) * 0.5 + 0.5;
|
||||
|
|
|
|||
Loading…
Reference in New Issue