50 lines
1.5 KiB
GLSL
50 lines
1.5 KiB
GLSL
#version 450
|
|
|
|
#ifdef GL_ES
|
|
precision mediump float;
|
|
#endif
|
|
|
|
uniform sampler2D tex;
|
|
|
|
in vec2 texCoord;
|
|
|
|
|
|
// Temporal Resolve Pixel Shader (Optional Pass)
|
|
|
|
float4 SMAAResolvePS(float2 texcoord,
|
|
SMAATexture2D(currentColorTex),
|
|
SMAATexture2D(previousColorTex)
|
|
#if SMAA_REPROJECTION
|
|
, SMAATexture2D(velocityTex)
|
|
#endif
|
|
) {
|
|
#if SMAA_REPROJECTION
|
|
// Velocity is assumed to be calculated for motion blur, so we need to
|
|
// inverse it for reprojection:
|
|
float2 velocity = -SMAA_DECODE_VELOCITY(SMAASamplePoint(velocityTex, texcoord).rg);
|
|
|
|
// Fetch current pixel:
|
|
float4 current = SMAASamplePoint(currentColorTex, texcoord);
|
|
|
|
// Reproject current coordinates and fetch previous pixel:
|
|
float4 previous = SMAASamplePoint(previousColorTex, texcoord + velocity);
|
|
|
|
// Attenuate the previous pixel if the velocity is different:
|
|
float delta = abs(current.a * current.a - previous.a * previous.a) / 5.0;
|
|
float weight = 0.5 * saturate(1.0 - sqrt(delta) * SMAA_REPROJECTION_WEIGHT_SCALE);
|
|
|
|
// Blend the pixels according to the calculated weight:
|
|
return lerp(current, previous, weight);
|
|
#else
|
|
// Just blend the pixels:
|
|
float4 current = SMAASamplePoint(currentColorTex, texcoord);
|
|
float4 previous = SMAASamplePoint(previousColorTex, texcoord);
|
|
return lerp(current, previous, 0.5);
|
|
#endif
|
|
}
|
|
|
|
|
|
void main() {
|
|
// gl_FragColor = vec4(col);
|
|
}
|