Files
UnrealEngineUWP/Engine/Shaders/VelocityCommon.usf
Matthew Griffin bb70b349ce Merging CL 2804086 from //UE4/Release-4.11 to Dev-Main (//UE4/Dev-Main) to isolate copyright update
#lockdown Nick.Penwarden

[CL 2819020 by Matthew Griffin in Main branch]
2016-01-07 08:17:16 -05:00

20 lines
748 B
Plaintext

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
VelocityCommon.usf: Common functions for calculating velocity vectors.
=============================================================================*/
#pragma once
float2 Calculate2DVelocity(float4 PackedVelocityA, float4 PackedVelocityC)
{
float2 ScreenPos = PackedVelocityA.xy / PackedVelocityA.w - ResolvedView.ViewToClip[2].xy;
float2 PrevScreenPos = PackedVelocityC.xy / PackedVelocityC.w - ResolvedView.PrevProjection[2].xy;
// 2d velocity, includes camera an object motion
float2 Velocity = ScreenPos - PrevScreenPos;
// Make sure not to touch 0,0 which is clear color
return Velocity;
}