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;
|
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 {
|
function brightnessToChar(b: number, x: number, y: number): string {
|
||||||
if (b < 0.05) return " ";
|
const c = contrastCurve(b);
|
||||||
const h = camHash(x, y, b);
|
if (c < 0.08) return " ";
|
||||||
if (b < 0.2) return CAM_DUST[h % CAM_DUST.length];
|
const h = camHash(x, y, c);
|
||||||
if (b < 0.45) return CAM_LOW[h % CAM_LOW.length];
|
if (c < 0.25) return CAM_DUST[h % CAM_DUST.length];
|
||||||
if (b < 0.7) return CAM_MID[h % CAM_MID.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];
|
return CAM_FULL[h % CAM_FULL.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,8 +46,9 @@ function brightnessToColor(
|
||||||
y: number,
|
y: number,
|
||||||
t: number
|
t: number
|
||||||
): string {
|
): string {
|
||||||
if (b < 0.05) return "";
|
const c = contrastCurve(b);
|
||||||
const clamped = Math.min(b, 1);
|
if (c < 0.08) return "";
|
||||||
|
const clamped = Math.min(c, 1);
|
||||||
|
|
||||||
// Slow-drifting phase creates shifting color bands across the frame
|
// 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;
|
const phase = Math.sin(x * 0.2 + y * 0.15 + t * 0.4) * 0.5 + 0.5;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue