summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/render/direct3d/D3D9_PixelShader_YUV.hlsl
blob: 880484807cf21b6e518e725f0bc086452724ad4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Texture2D theTextureY : register(t0);
Texture2D theTextureU : register(t1);
Texture2D theTextureV : register(t2);

SamplerState theSampler = sampler_state
{
    addressU = Clamp;
    addressV = Clamp;
    mipfilter = NONE;
    minfilter = LINEAR;
    magfilter = LINEAR;
};

struct PixelShaderInput
{
    float4 pos : SV_POSITION;
    float2 tex : TEXCOORD0;
    float4 color : COLOR0;
};

cbuffer Constants : register(b0)
{
    float4 Yoffset;
    float4 Rcoeff;
    float4 Gcoeff;
    float4 Bcoeff;
};


float4 main(PixelShaderInput input) : SV_TARGET
{
    float4 Output;

    float3 yuv;
    yuv.x = theTextureY.Sample(theSampler, input.tex).r;
    yuv.y = theTextureU.Sample(theSampler, input.tex).r;
    yuv.z = theTextureV.Sample(theSampler, input.tex).r;

    yuv += Yoffset.xyz;
    Output.r = dot(yuv, Rcoeff.xyz);
    Output.g = dot(yuv, Gcoeff.xyz);
    Output.b = dot(yuv, Bcoeff.xyz);
    Output.a = 1.0f;

    return Output * input.color;
}