keijiro / Klinker

Blackmagic DeckLink video capture/playback plugin for Unity.
The Unlicense
60 stars 6 forks source link

Video stream coming in with green/blue tint in Unity 2019.3.7f1 #8

Open thegladscientist opened 3 years ago

thegladscientist commented 3 years ago

Just did some testing back and forth with this and the AvPro Decklink plugin, and found that the quality was higher using this code. Unfortunately when using it in 2019.3.7 version of Unity (with HDRP) the video was coming in tinted blue/green. Of course I had to update the way that the RenderPipelineManager was calling beginCameraRendering to work with newer versions of HDRP, but after that I am facing this issue. Any insights would be incredible. 👍

Avpro: decklink capture 2 (quad scale 1)

Klinker on Standard Pipeline: keijiro capture 2

Klinker on HDRP in newer Unity editors: keijiro capture-HDRP

Ludwig-Karl commented 3 years ago

Same issue by me. I am also wondering if it is compatible with DX12 with the HDRP + DXR? Do you know something about it?

spxyz commented 3 years ago

Hello, it looks like it's all about gamma color space. Need some adjustments for linear version. I think it should work:


half4 uyvy = tex2D(_MainTex, uv);
    uyvy = LinearToGamma(uyvy);

half4 LinearToGamma(half4 col)
{
    if (col.r <= 0.0031308)
        col.r = col.r * 12.92;
    else
        col.r = 1.055 * pow(col.r, 0.4166667) - 0.055;
    if (col.g <= 0.0031308)
        col.g = col.g * 12.92;
    else
        col.g = 1.055 * pow(col.g, 0.4166667) - 0.055;
    if (col.b <= 0.0031308)
        col.b = col.b * 12.92;
    else
        col.b = 1.055 * pow(col.b, 0.4166667) - 0.055;
    col.a = col.a;
    return col;
}