Adding the velocity factor

This commit is contained in:
Sam Gateau 2017-08-17 01:29:12 -07:00
parent 4e574852cf
commit cbf5c25f35
4 changed files with 26 additions and 14 deletions

View file

@ -241,6 +241,7 @@ const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
void Antialiasing::configure(const Config& config) { void Antialiasing::configure(const Config& config) {
_params.edit().debugX = config.debugX; _params.edit().debugX = config.debugX;
_params.edit().blend = config.blend; _params.edit().blend = config.blend;
_params.edit().velocityScale = config.velocityScale;
} }

View file

@ -22,12 +22,14 @@ class AntialiasingConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
Q_PROPERTY(float debugX MEMBER debugX NOTIFY dirty) Q_PROPERTY(float debugX MEMBER debugX NOTIFY dirty)
Q_PROPERTY(float blend MEMBER blend NOTIFY dirty) Q_PROPERTY(float blend MEMBER blend NOTIFY dirty)
Q_PROPERTY(float velocityScale MEMBER velocityScale NOTIFY dirty)
public: public:
AntialiasingConfig() : render::Job::Config(true) {} AntialiasingConfig() : render::Job::Config(true) {}
float debugX{ 1.0f }; float debugX{ 0.0f };
float blend { 0.1f }; float blend{ 0.1f };
float velocityScale{ 1.0f };
signals: signals:
void dirty(); void dirty();
@ -35,9 +37,9 @@ signals:
struct TAAParams { struct TAAParams {
float debugX{ 1.0f }; float debugX{ 0.0f };
float blend{ 0.1f }; float blend{ 0.1f };
float spareA; float velocityScale{ 1.0f };
float spareB; float spareB;
}; };

View file

@ -29,7 +29,7 @@ struct TAAParams
{ {
float debugX; float debugX;
float blend; float blend;
float spareA; float motionScale;
float spareB; float spareB;
}; };
@ -43,21 +43,22 @@ void main() {
vec2 rawVelocity = texture(velocityMap, varTexCoord0).xy; vec2 rawVelocity = texture(velocityMap, varTexCoord0).xy;
vec2 velocity = rawVelocity; vec2 velocity = rawVelocity;
vec2 prevTexCoord = varTexCoord0 - velocity; vec2 prevTexCoord = varTexCoord0 - params.motionScale * velocity;
prevTexCoord = clamp(prevTexCoord, vec2(0.1), vec2(0.9));
vec3 prevColor = texture(historyMap, prevTexCoord).xyz; vec3 prevColor = texture(historyMap, prevTexCoord).xyz;
vec3 newColor = mix(currentColor, prevColor, params.blend); vec3 newColor = mix(prevColor, currentColor, params.blend);
outFragColor = vec4(newColor, 1.0); outFragColor = vec4(newColor, 1.0);
// outFragColor = vec4(varTexCoord0, 0.0, 1.0);
if (abs(varTexCoord0.x - params.debugX) < (1.0 / 2048.0)) { if (abs(varTexCoord0.x - params.debugX) < (1.0 / 2048.0)) {
outFragColor.rgb = vec3(1.0, 1.0, 1.0); outFragColor.rgb = vec3(1.0, 1.0, 0.0);
} }
if (varTexCoord0.x < params.debugX) { if (varTexCoord0.x < params.debugX) {
outFragColor = vec4(prevColor, 1.0); outFragColor = vec4(currentColor, 1.0);
/*if (dot(velocity, velocity) > 0.0001) { if (dot(velocity, velocity) > 0.0001) {
outFragColor = vec4(rawVelocity, 0.0, 1.0); outFragColor = vec4(0.0, 1.0, 1.0, 1.0);
}*/ }
} }
} }

View file

@ -28,13 +28,21 @@ Column {
min: 0.0 min: 0.0
} }
ConfigSlider { ConfigSlider {
label: qsTr("History blend") label: qsTr("Source blend")
integral: false integral: false
config: Render.getConfig("RenderMainView.Antialiasing") config: Render.getConfig("RenderMainView.Antialiasing")
property: "blend" property: "blend"
max: 1.0 max: 1.0
min: 0.0 min: 0.0
} }
ConfigSlider {
label: qsTr("Velocity scale")
integral: false
config: Render.getConfig("RenderMainView.Antialiasing")
property: "velocityScale"
max: 1.0
min: -1.0
}
CheckBox { CheckBox {
text: "Freeze " text: "Freeze "
checked: Render.getConfig("RenderMainView.JitterCam")["freeze"] checked: Render.getConfig("RenderMainView.JitterCam")["freeze"]