Closed geextahslex closed 3 months ago
st2094-10 in mpv is not a shader, it's C code:
https://code.videolan.org/videolan/libplacebo/-/blob/master/src/tone_mapping.c?ref_type=heads#L418
would it be possible to convert it into a glsl shader?
Of course, it's just code. What do you need it for?
I need it for https://github.com/natural-harmonia-gropius/hdr-toys, his pipeline is build (works best) with shaders. There are shaders for: reinhard, bt2446c, bt2390 etc. but obviously st2094-10 is missing, and it's my favourite one ^^
cc @natural-harmonia-gropius
would it be possible to convert it into a glsl shader? Of course, it's just code.
Thank you.
@geextahslex the shader is here, but no st2094_pick_knee()
, you need to modify x2
and y2
manually.
//!PARAM L_hdr
//!TYPE float
//!MINIMUM 0
//!MAXIMUM 10000
1000.0
//!PARAM L_sdr
//!TYPE float
//!MINIMUM 0
//!MAXIMUM 1000
203.0
//!PARAM CONTRAST_sdr
//!TYPE float
//!MINIMUM 0
//!MAXIMUM 1000000
1000.0
//!HOOK OUTPUT
//!BIND HOOKED
//!DESC tone mapping (st 2094-10)
const vec3 RGB_to_Y = vec3(0.2627002120112671, 0.6779980715188708, 0.05930171646986196);
float curve(float x) {
float x1 = 0.0;
float x2 = 0.7;
float x3 = L_hdr / L_sdr;
float y1 = 1.0 / CONTRAST_sdr;
float y2 = 0.18;
float y3 = 1.0;
float a = 1.0 / (x3 * y3 * (x1 - x2) + x2 * y2 * (x3 - x1) + x1 * y1 * (x2 - x3));
mat3 cmat = mat3(
x2 * x3 * (y2 - y3), x1 * x3 * (y3 - y1), x1 * x2 * (y1 - y2),
x3 * y3 - x2 * y2 , x1 * y1 - x3 * y3 , x2 * y2 - x1 * y1 ,
x3 - x2 , x1 - x3 , x2 - x1
);
vec3 coeffs = vec3(y1, y2, y3) * cmat * a;
float c1 = coeffs.r;
float c2 = coeffs.g;
float c3 = coeffs.b;
return (c1 + c2 * x) / (1.0 + c3 * x);
}
vec3 tone_mapping_y(vec3 RGB) {
float y = dot(RGB, RGB_to_Y);
return RGB * curve(y) / y;
}
vec4 hook() {
vec4 color = HOOKED_texOff(0);
color.rgb = tone_mapping_y(color.rgb);
return color;
}
Thank you, I played around with the settings. But there are oversaturated shadows, like in the screenshots blue tint and there is artifacting on the letterbox.
(both L_sdr=150)
reinhard (black_point_compensation /bottosson)
2094 (y2=0.40) ((no black_point_compensation /bottosson)
I like the luminance but the color feels of
reinhard
2094
reinhard
this should be black but its green ^^
2094
Try the updated one st2094-10, this set x2 and y2 automatically.
I will check artifacts in dark area later.
I looked into it
Ahsoka improved, I think the red seats should desaturate even more to get closer to reinhard.
There is a green tint in the blacks
You can see the green tint here, I boosted gamma by 50 to make it more visible. Reinhard also turns green eventually but its not noticable without any gamma boost.
Here the blue tint stayed the same, it should be blue but less (see reinhard screenshot)
And the artifacting on the letterbox is fixed Overall nice improvements Hopefully it can be later added to the portfolio ^^
tint
I committed changes, update it.
https://www.desmos.com/calculator/vjruzaxez0 curve here, you could draw reinhard with bpc your self for comparison.
Okay so I don't know why, the picture gets much darker now.
sigma0.5 here its the same picture as before but much darker
sigma1.0 fixed the green tint in the shadow in the seat
sigma1.0 it feels the same as before, but it is darker now
but much darker
try to change this value to 0.01 or 0.005
Okay it's brighter now, still a notch darker than yesterday but the seats look better now, color like reinhard :)
0.001 also works fine
OK, I updated them to 1.0 and 0.001
okay I feel like it's desaturated too much, the lights are no longer red
reinhard
2094
here you can see it's almost greyscale
2094
reinhard is maybe too saturated, I think something between them both would work the best
reinhard
I think something between them both would work the best
adjust sigma, back to 0.5 or try another value.
does someone have or know where to find the st2094-10 shader as glsl? I know that it is already implemented in mpv.
Thank you for any help