Skip to content

Commit

Permalink
2.2.2 - fixed washed out colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Egoistically committed Jan 13, 2022
1 parent 38d633f commit 0f12a63
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ Capture Card
## Download
Download the latest release from here: https://github.com/Egoistically/chiaki/releases/latest.

If you want to patch it yourself, [here's the the code changed](https://github.com/Egoistically/chiaki/commit/aedb17bf445c11ac7e563f461143cba3916260f3#diff-60660f571de143f23e1f2575ee8f83df4c6a4d0712720ed41d07ad404a8f67bb) (taken from here: https://stackoverflow.com/a/13097718).
If you want to patch it yourself, [here's the the code changed](https://github.com/Egoistically/chiaki/blob/master/gui/src/avopenglwidget.cpp#L32) (adapted from here: https://stackoverflow.com/q/55930123).

Because AppVeyor updates their images every so often, some changes might need to be made in the future.
Binary file modified assets/comparisons/bloodborne_fixed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/comparisons/bloodborne_original.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/comparisons/rpi_fixed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 17 additions & 8 deletions gui/src/avopenglwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,23 @@ uniform sampler2D plane3; // V
in vec2 uv_var;
out vec4 out_color;
void main()
{
highp float y = texture2D(plane1, uv_var).r;
highp float u = texture2D(plane2, uv_var).r - 0.5;
highp float v = texture2D(plane3, uv_var).r - 0.5;
highp float r = y + 1.402 * v;
highp float g = y - 0.344 * u - 0.714 * v;
highp float b = y + 1.772 * u;
const float yScale = 255.0 / (235.0 - 16.0);
const float uvScale = 255.0 / (240.0 - 16.0);
void main() {
float y = texture2D(plane1, uv_var).r;
float u = texture2D(plane2, uv_var).r - 0.5;
float v = texture2D(plane3, uv_var).r - 0.5;
y = y - 16.0/255.0;
float r = y*yScale + v*uvScale*1.5748;
float g = y*yScale - u*uvScale*1.8556*0.101 - v*uvScale*1.5748*0.2973;
float b = y*yScale + u*uvScale*1.8556;
r = clamp(r, 0.0, 1.0);
g = clamp(g, 0.0, 1.0);
b = clamp(b, 0.0, 1.0);
out_color = vec4(r,g,b,1.0);
}
Expand Down

7 comments on commit 0f12a63

@Entropy512
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, the PS sends out legal range and not data range luma? That surprises me, I would have expected remote play to send data range.

@Egoistically
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I don't have any idea what I did here. I went for the fastest, most braindead fix I could come up with to continue playing Bloodborne asap. So I am deeply sorry for the abomination this may be.

@Entropy512
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those conversions are correct for legal range luma - https://www.lightillusion.com/data_legal_levels.html

I'm just surprise that the console is sending legal range luma. There might be some undesired conversion happening earlier in the pipeline, or possibly an as yet undocumented parameter when requesting the stream.

I just upgraded from PS4 to PS5 and only recently discovered chiaki - Is this something that was working OK and was broken by a PlayStation update, or has it always been problematic?

@Entropy512
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, looks like the console has always been that way - but whatever you did at aedb17b#diff-60660f571de143f23e1f2575ee8f83df4c6a4d0712720ed41d07ad404a8f67bb reverted this routine to a a very old (and apparently broken) state

@Egoistically
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik, chiaki has had problems with inaccurate color for quite a while (if not since the beginning).
I happened to notice yellows were really off compared to the official Remote Play app, so I tried different conversions until I found one that looked better. But I have no idea how things really work, what the console really sends, or color theory in general.

Any input will be appreciated.

@willianholtz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could try replicating that same color tone using Nvidia's board:

static const char *nv12_shader_frag_glsl = R"glsl(

I tested this patch of yours, and it's perfect! Can you apply the fix for nvidia?
My test, in the "decode" of chiaki, it only works if I leave it in "none" If I use vdpau or CUDA, the yellowing still persists.

@S703T
Copy link

@S703T S703T commented on 0f12a63 Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please make a build for switch? i tried to do it myself but cmake sucks

Please sign in to comment.