Files
UnrealEngineUWP/Engine/Shaders/Private/InstancedStereo.ush
Marc Audy 360d078ca3 Second batch of remaining Engine copyright updates.
#rnx
#rb none

[CL 10871248 by Marc Audy in Main branch]
2019-12-27 09:26:59 -05:00

70 lines
1.6 KiB
Plaintext

// Copyright 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 "/Engine/Generated/UniformBuffers/View.ush"
#include "/Engine/Generated/UniformBuffers/InstancedView.ush"
// ViewState, GetPrimaryView and GetInstancedView are generated by the shader compiler to ensure View uniform buffer changes are up to date.
// see GenerateInstancedStereoCode()
#include "/Engine/Generated/GeneratedInstancedStereo.ush"
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) };
#endif
// Generated for Metal in GeneratedInstancedStereo.usf
#if !(COMPILER_METAL && (COMPILER_HLSLCC == 1)) && (INSTANCED_STEREO || MOBILE_MULTI_VIEW)
ViewState ResolveView(uint ViewIndex)
{
if (ViewIndex == 0)
{
return GetPrimaryView();
}
else
{
return GetInstancedView();
}
}
#endif
bool IsInstancedStereo()
{
#if INSTANCED_STEREO
return InstancedView_StereoPassIndex > 0;
#else
return false;
#endif
}
uint GetEyeIndex(uint InstanceId)
{
#if INSTANCED_STEREO
return IsInstancedStereo() ? InstanceId & 1 : 0;
#else
return 0;
#endif
}
uint GetInstanceId(uint InstanceId)
{
#if INSTANCED_STEREO
return IsInstancedStereo() ? InstanceId / 2 : InstanceId;
#else
return InstanceId;
#endif
}