You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- PR #9563 contributed by tuxerr, with modifications - InstancedView UB duplicates per-view View UB properties in arrays and uses ViewIndex to index into them when creating resolved ViewState (instead of a branch). - Paves the way for potential "always-on ISR". #jira UE-163717 #review @Robert.Srinivasiah, @Christopher.Waters, @Yuriy.ODonnell, @Jules.Blok #preflight 6386ed9b170bc34a93076918 #rb Yuriy.ODonnell [CL 23341764 by tuxerr in ue5-main branch]
79 lines
2.7 KiB
Plaintext
79 lines
2.7 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"
|
|
|
|
void FinalizeViewState(inout ViewState InOutView)
|
|
{
|
|
InOutView.WorldToClip = MakeLWCInverseMatrix(InOutView.MatrixTilePosition, InOutView.RelativeWorldToClip);
|
|
InOutView.ClipToWorld = MakeLWCMatrix(InOutView.MatrixTilePosition, InOutView.ClipToRelativeWorld);
|
|
InOutView.ScreenToWorld = MakeLWCMatrix(InOutView.MatrixTilePosition, InOutView.ScreenToRelativeWorld);
|
|
InOutView.PrevClipToWorld = MakeLWCMatrix(InOutView.MatrixTilePosition, InOutView.PrevClipToRelativeWorld);
|
|
|
|
InOutView.WorldCameraOrigin = MakeLWCVector3(InOutView.ViewTilePosition, InOutView.RelativeWorldCameraOrigin);
|
|
InOutView.WorldViewOrigin = MakeLWCVector3(InOutView.ViewTilePosition, InOutView.RelativeWorldViewOrigin);
|
|
InOutView.PrevWorldCameraOrigin = MakeLWCVector3(InOutView.ViewTilePosition, InOutView.PrevRelativeWorldCameraOrigin);
|
|
InOutView.PrevWorldViewOrigin = MakeLWCVector3(InOutView.ViewTilePosition, InOutView.PrevRelativeWorldViewOrigin);
|
|
InOutView.PreViewTranslation = MakeLWCVector3(-InOutView.ViewTilePosition, InOutView.RelativePreViewTranslation);
|
|
InOutView.PrevPreViewTranslation = MakeLWCVector3(-InOutView.ViewTilePosition, InOutView.RelativePrevPreViewTranslation);
|
|
}
|
|
|
|
#define PrimaryView GetPrimaryView()
|
|
|
|
static ViewState ResolvedView = (ViewState)0.0f;
|
|
|
|
ViewState ResolveView()
|
|
{
|
|
return GetPrimaryView();
|
|
}
|
|
|
|
#if (INSTANCED_STEREO || MOBILE_MULTI_VIEW)
|
|
ViewState ResolveView(uint ViewIndex)
|
|
{
|
|
return GetInstancedView(ViewIndex);
|
|
}
|
|
#endif
|
|
|
|
#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
|
|
|
|
bool IsInstancedStereo()
|
|
{
|
|
#if INSTANCED_STEREO
|
|
return (uint)InstancedView_StereoPassIndex[1] > 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
|
|
}
|