From 349d54306a32fcb047bb83c210bc0f5dfaea0d6a Mon Sep 17 00:00:00 2001 From: meleki Date: Sat, 12 Sep 2026 22:48:57 +0200 Subject: [PATCH] Shaders: brightness adds instead of multiplying in the Adjust colors recipe --- Shaders.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Shaders.md b/Shaders.md index 7001232..6a4fe67 100644 --- a/Shaders.md +++ b/Shaders.md @@ -39,18 +39,19 @@ Brightness, contrast and saturation with **1 as neutral** on every one, on the s transparent pixel never gains colour: ``` -rgb = rgb * brightness +rgb = rgb + (brightness - 1) rgb = (rgb - 0.5) * contrast + 0.5 rgb = mix(luminance(rgb), rgb, saturation) ``` -As nodes: `Texture color` → `Multiply` (b: Property *brightness*) → `Subtract` (b: 0.5) → -`Multiply` (b: Property *contrast*) → `Add` (b: 0.5) → both into `Luminance` and into `Mix` as -`b`, `Luminance` into `Mix` as `a`, Property *saturation* into `t`, `Mix` into `Output`. Three -`Property` nodes with default 1, min 0, max 4. The test fixture and the three example games ship +Brightness adds, contrast multiplies, saturation blends; with every value at 1 the pixel is +untouched. As nodes: Property *brightness* → `Subtract` (b: 1) → `Add` as `b`, with +`Texture color` as `a` → `Subtract` (b: 0.5) → `Multiply` (b: Property *contrast*) → `Add` +(b: 0.5) → both into `Luminance` and into `Mix` as `b`, `Luminance` into `Mix` as `a`, Property +*saturation* into `t`, `Mix` into `Output`. Three `Property` nodes with default 1, min 0, max 4. The test fixture and the three example games ship this graph as the asset "Adjust colors" (`tools/lib/shaders.mjs`). -Measured on a flat `#4080ff` sprite: brightness 0.5 gives `#204080`, contrast 0 gives `#808080`, +Measured on a flat `#4080ff` sprite: brightness 1.25 gives `#80c0ff`, contrast 0 gives `#808080`, saturation 0 gives `#7c7c7c` — all byte-exact against the formula. ## Wearing a shader