Files
UnrealEngineUWP/Engine/Shaders/VelocityCommon.usf
Martin Mittring e75acb9b8a Merging from Orion
CL 2699552
  added SvPositionToTranslatedWorld for better quality and performance, some refactoring

[CL 2699586 by Martin Mittring in Main branch]
2015-09-21 15:59:33 -04:00

20 lines
732 B
Plaintext

// Copyright 1998-2015 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 - View.ViewToClip[2].xy;
float2 PrevScreenPos = PackedVelocityC.xy / PackedVelocityC.w - View.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;
}