54 lines
1.1 KiB
HLSL
54 lines
1.1 KiB
HLSL
struct VSOut
|
|
{
|
|
float4 position : SV_Position;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
cbuffer FrameConstants : register(b0)
|
|
{
|
|
float width;
|
|
float height;
|
|
float frameIndex;
|
|
float frameReserved;
|
|
};
|
|
|
|
cbuffer ShaderParameters : register(b1)
|
|
{
|
|
float amount;
|
|
float3 parameterPadding;
|
|
};
|
|
|
|
Texture2D<float4> inputFrame : register(t0);
|
|
SamplerState linearClampSampler : register(s0);
|
|
|
|
VSOut fullscreen_vs(uint vertexId : SV_VertexID)
|
|
{
|
|
float2 positions[3] =
|
|
{
|
|
float2(-1.0, -1.0),
|
|
float2(-1.0, 3.0),
|
|
float2( 3.0, -1.0)
|
|
};
|
|
|
|
float2 uvs[3] =
|
|
{
|
|
float2(0.0, 1.0),
|
|
float2(0.0, -1.0),
|
|
float2(2.0, 1.0)
|
|
};
|
|
|
|
VSOut output;
|
|
output.position = float4(positions[vertexId], 0.0, 1.0);
|
|
output.uv = uvs[vertexId];
|
|
return output;
|
|
}
|
|
|
|
float4 main(VSOut input) : SV_Target
|
|
{
|
|
float4 color = inputFrame.Sample(linearClampSampler, input.uv);
|
|
float luminance = dot(color.rgb, float3(0.2126, 0.7152, 0.0722));
|
|
float3 gray = luminance.xxx;
|
|
color.rgb = lerp(color.rgb, gray, saturate(amount));
|
|
return color;
|
|
}
|