overte-HifiExperiments/libraries/render-utils/src/taa.slf
2018-10-29 16:42:46 -07:00

45 lines
1.3 KiB
Text

<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// taa.frag
// fragment shader
//
// Created by Sam Gateau on 8/14/2017
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include taa.slh@>
layout(location=0) in vec2 varTexCoord0;
layout(location=0) out vec4 outFragColor;
void main() {
vec2 fragUV = varTexCoord0;
// Debug region before debug or fxaa region X
float distToRegionFXAA = fragUV.x - taa_getRegionFXAA().x;
if (distToRegionFXAA > 0.0) {
outFragColor = vec4(taa_evalFXAA(fragUV), 1.0);
return;
}
vec2 fragVel = taa_fetchVelocityMapBest(fragUV).xy;
vec3 sourceColor;
vec3 historyColor;
vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV, fragVel, sourceColor, historyColor);
vec3 nextColor = sourceColor;
// clamp history to neighbourhood of current sample
historyColor = mix(historyColor, taa_evalConstrainColor(sourceColor, fragUV, fragVel, historyColor), float(taa_constrainColor()));
nextColor = mix(mix(historyColor, sourceColor, params.blend), taa_evalFeedbackColor(sourceColor, historyColor, params.blend), float(taa_feedbackColor()));
outFragColor = vec4(taa_resolveColor(nextColor), 1.0);
}