Files
UnrealEngineUWP/Engine/Shaders/InstancedStereo.usf
Ben Marsh 20bf0eb6a1 Updating copyright notices to 2017 (copying from //Tasks/UE4/Dev-Copyright-2017).
#rb none
#lockdown Nick.Penwarden

[CL 3226823 by Ben Marsh in Main branch]
2016-12-08 08:52:44 -05:00

62 lines
1.5 KiB
Plaintext

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved..
/*=============================================================================
InstancedStereo.usf: Resolve which view uniforms in a stereo pair to use.
=============================================================================*/
#pragma once
// Explictly include view uniform buffers
#include "UniformBuffers/View.usf"
#include "UniformBuffers/InstancedView.usf"
// ViewState, GetPrimaryView and GetInstancedView are generated by the shader compiler to ensure View uniform buffer changes are up to date.
// see GenerateInstancedStereoCode()
#include "GeneratedInstancedStereo.usf"
// Packing the eye index and instanced stereo flag into a single uint to save an interpolator
uint PackEyeIndex(uint EyeIndex, bool bIsInstancedStereo)
{
uint Result = 0;
Result |= (uint)bIsInstancedStereo << 31;
Result |= EyeIndex;
return Result;
}
uint GetEyeIndex(uint PackedIndex)
{
return PackedIndex & 0x1;
}
bool IsInstancedStereo(uint PackedIndex)
{
return (PackedIndex >> 1) > 0;
}
static ViewState ResolvedView;
ViewState ResolveView()
{
return GetPrimaryView();
}
#if INSTANCED_STEREO
static const float EyeOffsetScale[2] = { -1.0, 1.0 };
static const float4 EyeClipEdge[2] = { float4(-1.0, 0.0, 0.0, 1.0), float4(1.0, 0.0, 0.0, 1.0) };
bool bIsInstancedStereo;
#endif
#if INSTANCED_STEREO || MOBILE_MULTI_VIEW
ViewState ResolveView(uint ViewIndex)
{
if (ViewIndex == 0)
{
return GetPrimaryView();
}
else
{
return GetInstancedView();
}
}
#endif