Skip to content

Commit

Permalink
utils/diff: compute difference in linear space
Browse files Browse the repository at this point in the history
The alpha is not gamma compressed (not part of sRGB) so the computation
remains the same for this channel.
  • Loading branch information
ubitux committed Nov 18, 2022
1 parent ad7c597 commit 1fa4d19
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ for the globale releases (`YYYY.MINOR`), and to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html) for `libnodegl`.

## [Unreleased]
### Fixed
- Color channel difference in `ngl-diff` is now done in linear space

## [2022.8] [libnodegl 0.6.1] - 2022-09-22
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pynodegl-utils/pynodegl_utils/diff/shaders/diff.frag
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ vec3 lin_mix(vec3 c0, vec3 c1, float v) { return lin2srgb(mix(srgb2lin(c0), srgb
vec4 color_diff(vec4 c0, vec4 c1)
{
float n = float(show_r) + float(show_g) + float(show_b) + float(show_a);
vec4 diff = c0 - c1;
vec4 diff = vec4(srgb2lin(c0.rgb), c0.a) - vec4(srgb2lin(c1.rgb), c1.a);
vec4 diff2 = diff * diff * vec4(show_r, show_g, show_b, show_a); // filtered squared difference
float sum = diff2.r + diff2.g + diff2.b + diff2.a;
float err = sqrt(sum / n);
Expand Down

0 comments on commit 1fa4d19

Please sign in to comment.