80 lines
1.9 KiB
HLSL
80 lines
1.9 KiB
HLSL
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SMAACommon.ush"
|
|
|
|
struct FSMAADebugVisualizationVertexOutput
|
|
{
|
|
noperspective float2 UV : TEXCOORD0;
|
|
float4 Offset : TEXCOORD1;
|
|
float4 Position : SV_POSITION;
|
|
};
|
|
|
|
Texture2D EdgeTex;
|
|
Texture2D BlendTex;
|
|
|
|
int DebugMode;
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
vertex shader
|
|
-----------------------------------------------------------------------------*/
|
|
#ifdef MainVS
|
|
|
|
void MainVS(
|
|
float2 InPosition : ATTRIBUTE0,
|
|
float2 InUV : ATTRIBUTE1,
|
|
out FSMAADebugVisualizationVertexOutput Output
|
|
)
|
|
{
|
|
DrawRectangle( float4( InPosition, 0, 1 ), InUV, Output.Position, Output.UV);
|
|
|
|
SMAANeighborhoodBlendingVS(Output.UV, Output.Offset);
|
|
}
|
|
|
|
#endif // MainVS
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
pixel shader
|
|
-----------------------------------------------------------------------------*/
|
|
#ifdef MainPS
|
|
|
|
void MainPS(
|
|
FSMAADebugVisualizationVertexOutput Input,
|
|
out float4 OutColor : SV_Target0)
|
|
{
|
|
float4 color = float4(0,0,0,0);
|
|
|
|
if (DebugMode == 1)
|
|
{
|
|
color = EdgeTex.Sample(LinearSampler, Input.UV);
|
|
}
|
|
else if (DebugMode == 2)
|
|
{
|
|
color = BlendTex.Sample(LinearSampler, Input.UV);
|
|
}
|
|
else if (DebugMode == 3)
|
|
{
|
|
// sampling logic taken from SMAANeighborhoodBlendingPS, in SMAA.ush
|
|
|
|
// Fetch the blending weights for current pixel:
|
|
float4 a;
|
|
a.x = BlendTex.Sample(LinearSampler, Input.Offset.xy).a; // Right
|
|
a.y = BlendTex.Sample(LinearSampler, Input.Offset.zw).g; // Top
|
|
a.wz = BlendTex.Sample(LinearSampler, Input.UV).xz; // Bottom / Left
|
|
|
|
// Is there any blending weight with a value greater than 0.0?
|
|
if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5)
|
|
{
|
|
color = Input_Texture.SampleLevel(LinearSampler, Input.UV, 0);
|
|
}
|
|
else
|
|
{
|
|
color = float4(1.0, 0.0, 0.0, 0.0);
|
|
}
|
|
}
|
|
|
|
OutColor = color;
|
|
}
|
|
|
|
#endif // MainPS
|