我有一种将YUV转换为RGB的着色器。
struct Pixel_INPUT
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
Texture2D textureY : register(t0);
Texture2D textureU : register(t1);
Texture2D textureV : register(t2);
SamplerState samstate
{
MinFilter = Anisotropic;
MagFilter = Anisotropic;
AddressU = Clamp;
AddressV = Clamp;
};
float4 PS(Pixel_INPUT input) : SV_Target
{
float y = (1.1643f * textureY.Sample(samstate,input.tex) - 0.0625f);
float u = textureU.Sample(samstate,input.tex) - 0.5f;
float v = textureV.Sample(samstate,input.tex) - 0.5f;
float r = y + 1.5958f * v;
float g = y - 0.39173f * u - 0.81290f * v;
float b = y + 2.017f * u;
return float4(r,g,b,1);
}
但是我有一条绿线在图片的右边,像这样:
![enter image description here](https://istack.dev59.com/OnJFp.webp)