bjin / mpv-prescalers

prescalers for mpv, as user shaders
GNU Lesser General Public License v3.0
355 stars 34 forks source link

Shader from HLSL, how to obtain the .hook? #34

Closed orator89 closed 5 years ago

orator89 commented 5 years ago

Hi, I normally use MPC-HC, but now use MPV because of the better cpu/gpu usage. Only there's a pixel shader (.HLSL) on MPC that I want to use as shader on MPV, is it possible to generate the .hook/.glsl equivalent? this is the small code of the pixel shader .hlsl, that converts colors 16-235 to 0-255:

sampler s0 : register(s0);

#define const_1 ( 16.0 / 255.0)
#define const_2 (255.0 / 219.0)

float4 main(float2 tex : TEXCOORD0) : COLOR
{
    // original pixel
    float4 c0 = tex2D(s0, tex);

    return ((c0 - const_1) * const_2);
}

Thanks

haasn commented 5 years ago

Mpv should detect TV/PC range automatically. If the file is mistagged, you can override it with --vf=format:colorlevels=limited.

bjin commented 5 years ago

I don't know much about MPC-HC's pixel shader, but this shader itself doesn't look correct.

The tv range for luma and chroma are different (235 vs 240 I believe). So it's incorrect to process it in RGB colorspace (I assume MPC-HC's pixel shader works only on merged RGB), and it's incorrect to use only luma range.

orator89 commented 5 years ago

I understood your replies.. but the effect the shader produces in mpc-hc is great, It doesn't matter if it's incorrect, I like it... It's a small code, is it possible to convert? I already tested the

--vf=format:colorlevels=limited

and

--vf=format:colorlevels=full

they aren't the same as the mpc shader... Please help.. I want MPV looks as mpc-hc with this shader...

bjin commented 5 years ago

@orator89 It's a fairly easy shader to port, to be frank. But I myself won't port a shader which is known to be wrong, just because it happens to looks "great" to some random eyes.