Shaders: brightness adds instead of multiplying in the Adjust colors recipe
1 parent
a0fad88eb2
commit
349d54306a
1 file changed
+7
-6
+7
-6
@@ -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
|
||||
|
||||
Reference in new issue
Block a user