2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "PostProcess/PostProcessHMD.h"
|
|
|
|
|
#include "EngineGlobals.h"
|
|
|
|
|
#include "Engine/Engine.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
#include "IHeadMountedDisplay.h"
|
Copying //UE4/Dev-VR to //UE4/Dev-Main (Source: //UE4/Dev-VR @ 3636795)
#lockdown Nick.Penwarden
============================
MAJOR FEATURES & CHANGES
============================
Change 2932765 by Nick.Whiting
Merging updated license files for Oculus libraries
Change 3480552 by Dustin.Holmes
Added map and gamemode for calibration
#jira UEVR-808
Change 3502253 by Nick.Whiting
Trying to fix up p4's botch of the merge
Change 3513736 by Keli.Hlodversson
Move duplicated late update code into a common FLateUpdateManager
#jira UEVR-893
Change 3514798 by Mike.Beach
#4.17
Exposing a way for Blueprint users to remap the SteamVR controller's d-pad buttons (clashes with the Oculus mappings).
#jira UE-42634
Change 3516042 by Dustin.Holmes
Runtime handedness changes in Vive controllers are now reflected when a new device is connected. Device mappings are also reset when a device disconnects, so that if it connects again it fully reregisters instead of just assuming the role it previously had.
Change 3517781 by Keli.Hlodversson
Remove unused local variable bUseCustomPresentTexture
Change 3517951 by Mike.Beach
#4.17
Guarding against dereferencing a null pointer. Defaulting to the identity when we don't (yet) have a valid head pose to use.
#jira UE-43685
Change 3518142 by Mike.Beach
#4.17
Resolving fallout from bad merge (CL 3514868) - checking for teminating null in array (which was added to keep ARRAY_COUNT from acting on an empty array).
Change 3523183 by Ryan.Vance
#jira UE-46493, UEVR-661
Fixes GearVR only displaying a black screen on startup
Fixes GearVR rendering incorrectly with mobile multi-view w/o direct mode enabled
Adding mobile multi-view direct support to Daydream
Change 3523718 by Nick.Whiting
Adding core controller recentering delegate, and moving Google over to that system.
Change 3527263 by Dan.Oconnor
Mirror 3526925 for Nick Donaldson
Change 3533596 by Dustin.Holmes
Add garbage matte map, gamemode, and blueprints.
Change 3533598 by Dustin.Holmes
Expose the Set Tint Color and Opacity function for Widget Components as a Blueprint node.
Change 3538139 by Mike.Beach
Moving Oculus debug shader directly into Oculus plugin.
#jira UE-47134
Change 3543185 by Nick.Atamas
Address UEVR-891 : Merge in changes to Google Tango plugin.
#jira UEVR-891
Change 3543285 by Nick.Atamas
Merging using //UE4/Release-4.17/... -> //UE4/Dev-VR/... :
Fixed UEVR-852:
Adjusted Google Tango Plugins copyright to Copyright Google 2017.
Removed Apache 2.0 license.
Change 3545505 by Nick.Atamas
Fix UEVR-851 : some fix-ups to MeshReconHUD and overlay material now has a material parameter for tinting the reconstructed mesh to help debug visualization.
Change 3547549 by Jeff.Fisher
Fixing DefaultSpectatorScreenController comment.
Change 3551339 by Ryan.Vance
#jira UE-44947
Editor primitives we not being handled correctly with ISR.
Change 3554169 by Dustin.Holmes
Reconcile missed Mixed Reality blueprint
Change 3566825 by Mike.Beach
Fixing some bad merges from Main (fallout from CL 3566309)
Change 3567143 by Mike.Beach
Copying //Tasks/UE4/Dev-MixedReality to Dev-VR-Minimal (//UE4/Dev-VR-Minimal)
Change 3567572 by Mike.Beach
[WIP] Adding some MR plugin dependencies to keep CIS quiet (SteamVR is just temporary, and will be removed).
Change 3569116 by Jeff.Fisher
Mixed reality build breaks for PS4
-Module is dependent on steamvr, so don't build it for PS4.
-Removed unused class that doesn't compile with clang.
Change 3569362 by Mike.Beach
Organizing MR plugin content, to make way for new calibration modes.
Change 3572802 by Jeff.Fisher
UEVR-832 Add save/load system for calibrated camera settings
-Moved MixedRealityConfigurationSaveGame to c++.
#review-3571779
#jira UEVR-832
Change 3573864 by Mike.Beach
[WIP] Initial work on MR cam alignment controller - records point/frustum data from user input.
Change 3575900 by Jeff.Fisher
Vive spectator flat rect expanded to match other platforms.
-The vive 'full flat eye' rect was narrower than other platforms. Expanded it to be closer to the other platforms.
Change 3578684 by Mike.Beach
Static analysis fixes for CIS.
#jira UE-48204, UE-48203, UE-48206
Change 3579460 by Mike.Beach
[WIP] New calibration mode for camera alignment.
#jira UEVR-785
Change 3581232 by Mike.Beach
[WIP] Saving off alignment calibration data, and loading it on initialization. We skip alignment calibration if it has been configured.
#jira UEVR-832
Change 3588411 by Mike.Beach
[WIP] Adding calibration for compositing (chroma color, etc.).
#jira UEVR-785
Change 3588541 by Mike.Beach
[WIP] Cleaning up some display issues with the MR calibration.
#jira UEVR-785
Change 3588680 by Mike.Beach
Re-organizing the MR content, now that the alignment controller calibrates more than just alignment (renaming, etc.).
Change 3588694 by Mike.Beach
Renaming the MR calibration pawn (since it doesn't do any calibrating itself).
Change 3591518 by Mike.Beach
Copying //Tasks/UE4/Dev-MixedReality to Dev-VR-Minimal (//UE4/Dev-VR-Minimal)
Change 3591671 by Ryan.Vance
Debug stereo layer support
This adds an option to render the debug canvas to a stereo layer which greatly improves console and stat readability in an hmd.
Change 3591812 by Ryan.Vance
Don't snap motion controllers to the origin when tracking is lost.
Change 3594681 by Mike.Beach
[WIP] Copying //Tasks/UE4/Dev-MixedReality to Dev-VR-Minimal (//UE4/Dev-VR-Minimal)
Change 3596679 by Mike.Beach
CIS fix (likely fallout from CL 3591671) - changing the order of initialization to better match the order of declaration.
Change 3598191 by Jeff.Fisher
UEVR-807 Setup M_MRVidProcessing to use 3D garbage matte data.
-Created MixedRealityGarbageMatteCaptureComponent. An instance of this is spawned by and attached to MixedRealityCaptureComponent. Saved config data is loaded into it. It spawns a garbage matte actor. It then captures the garbage matte actor into a render target (which is set on MixedRealityCaptureComponent).
#jira UEVR-807
#review-3598179
Change 3598276 by Mike.Beach
Copying //Tasks/UE4/Dev-MixedReality to Dev-VR-Minimal (//UE4/Dev-VR-Minimal)
Change 3598332 by Mike.Beach
Guarding against a blind cast in the SteamVRChaperone component, which can be used cross platform (can't assume SteamVR).
Change 3605271 by Mike.Beach
Copying //Tasks/UE4/Dev-MixedReality to Dev-VR-Minimal (//UE4/Dev-VR-Minimal)
Change 3608490 by Jeff.Fisher
UEVR-987 Social Screen PS4 need to go to 'mirroring' for hmd setup dialog because system dialogs are not visible in separate mode.
UEVR-988 SpectatorScreen Flickering
UE-47234 Spectator screen: need frame delay before assigning dynamically created rendertarget to spectator texture
UE-47310 Spectator Screen: crash if you release a render target which is assigned as the spectator texture
-Test level content for all of these bugs.
Change 3608883 by Jeff.Fisher
UEVR-807 Setup M_MRVidProcessing to use 3D garbage matte data.
-Set material to use the garbage matte render target.
Change 3613292 by Mike.Beach
Moving header fcn decl up, under the proper interface section (for organization's sake).
Change 3616943 by Nick.Whiting
Updating SteamVR libraries to 1.0.9, so we can bring back macOS support
Change 3616970 by Nick.Whiting
Adding in steamvr visible area mesh support. Can be toggled with vr.SteamVR.UseVisibleAreaMesh
Change 3617866 by Mike.Beach
Updating the VR template to reflect Oculus HMD device naming that we've keyed off of in these Blueprints (when determining which VR system we're running on).
Change 3620108 by Mike.Beach
[WIP] Adding an intermediate calibration step to tweak the MR virtual cam's alignment.
Change 3620982 by Mike.Beach
Tying off some loose ends with the MR calibration map:
* Saving after each calibration phase
* Fixing blocked input from garbage matte creation
* Blocking input handling while exiting/previewing
* Adding minimum radius for random screen pt
Change 3621551 by Mike.Beach
[MR] Leveraging camera support in the new media framework - working for limited cameras in calibration.
Change 3621552 by Mike.Beach
[MR calibration] - fixing it so when you first switch into compoisiting calibration it updates the property readout.
Change 3621660 by Mike.Beach
[MR calibration] Cleaning up how we display text (adding a struct to wrap the coresponding properties).
Change 3623323 by Dustin.Holmes
Fix buffer overflow when using 5+ Vive generic trackers and add more Special hand designations to cover the maximum 11 trackers Vive supports
Change 3625900 by Keli.Hlodversson
Remove fixed 16:9 aspect ratio for SteamVR and Oculus splash screens.
Oculus was already fixed in CL#3413801, but regressed with plugin renaming and unificiation with GearVR in CL#3502152.
#jira UE-40220 StereoLayer splash layers are hardcoded to 8 by 4.5 meters (16:9 aspect ratio)
Change 3628409 by Mike.Beach
Speculative CIS fix.
#jira UE-49339
Change 3628440 by Nick.Whiting
Fix for SteamVR OSX build issues
Change 3628489 by Nick.Whiting
Fix for win32 build break
Change 3629045 by Mike.Beach
Shadowed variable name fix (CIS).
Change 3629202 by Arciel.Rekman
Copying //UE4/Partner-Valve@3629179 to Dev-VR (//UE4/Dev-VR)
Change 3629340 by Nick.Atamas
Unshelved and resolved changes from Oculus.
Change 3629772 by Ryan.Vance
Fixing Oculus Vulkan related compile issues. This will break Oculus Vulkan support, but the code needs to be refactored anyway.
Change 3629833 by Mike.Beach
Fixing up CIS warning introduced by Oculus 1.17 changes - "unsafe conversion" warning
#jira UE-49376
Change 3630696 by Jeff.Fisher
UE-49415 //UE4/Dev-VR: Incremental UE4Editor Win64 completed with errors - 5 Errors
Switching an include to a forward declaration
-Not sure why the previous version didn't compile on the build machine, but fewer dependencies is good.
Change 3630783 by Mike.Beach
Fixing CIS compiler failures for our vehicle templates.
#jira UE-49417
Change 3630802 by Mike.Beach
Better fix than 3630783 - updating the vehicle template's stereoscopic check (fixing the VehicleHud.cpp logic as well)
#jira UE-49417
Change 3630870 by Mike.Beach
Pragma'ing out a function pointer cast warning. Good warning, but I figure we know what we're doing here and there's no other way around it.
#jira UE-49376
Change 3630993 by Ryan.Vance
Check to ensure we have a valid third camera before trying to use it.
We could check >= 3 or if the left and right cameras are left/right stereo etc. decided to go with the simple test for now.
Change 3631322 by Jeff.Fisher
UEVR-909 PIP in Garbage Matte
-Added ExternalGarbageMatteActor to MixedRealityGarbageMatteCaptureComponent and exposed it to blueprint though MixedRealityCaptureComponent. This lets us switch from using the normal mixed reality component save/load garbage matte data and instead use an external actor, in this case the actor we use to setup the garbage matte. Then the mask is able to capture that actor live as it is edited.
-Also implemented GetViewOwner() so that we can use SetOwnerOnlySee to prevent other cameras and captures from seeing the garbage matte actor.
-Calibration level now uses the external garbage matte actor to let the garbate matte mask live update. It also does a picture-in-picture preview of the mixed reality scene. 'P' can show/hide the garbage matte actor on that PIP preview.
-Added SetUnmaskedPixelHighlightColor to MixedRealityCaptureComponent and the material. With this one can make unmasked video pixels more obvious in the output. The calibration level has this mapped to shift-P and makes pixels bright yellow to white.
-Added blueprint to calibration level to make the garbage matte actor visible in the mixed reality capture. That is bound to ctrl-g.
-GarbageMatteActors spawned by the mixed reality capture component are now attached to the vr origin. The calibration level now saves garbage matte mesh transforms relative to the vr origin.
-The garbage matte mesh is now plugin content, and is referenced in the mixedrealitycomponent default object, so it is cooked in any project that includes the plugin.
-Fog and AtmosphericFog no longer affect the garbage matte mask capture... there may be other things we need to turn off there.
#review-3618345
#jira UEVR-909
Change 3631362 by Keli.Hlodversson
#jira UE-49418 Exiting Google Instant Preview displays half of the editor viewport as black.
Note convoluted fix: passing bIsStereoScopic3D to IsActiveThisFrame. ISceneViewExtension code cannot rely on StereoRenderingDevice->IsStereoEnabled to know whether to render in stereo, as the current viewport widget may disable it. This was not a problem before the refactoring, as HMD-related viewextensions were only added to the active list after establishing that stereo indeed was enabled and allowed by the current view port widget.
Change 3631887 by Jeff.Fisher
Fixing IsActiveThisFrame build break.
Change 3632206 by Nick.Atamas
Fix for UE-49413.
Registering FOculusHMD as an extensions the same way as others: now creates an XRCamera that passes all the calls back to the HMD.
Change 3632264 by Nick.Whiting
Fix for Vive rendering getting cropped off due to invalid subrect values being submitted to the compositor.
Change 3632340 by Nick.Atamas
Merged in change from Loren; opted for our solution to ViewExtensions instead of the one in the changelist.
Original description below.
Change 3632214 by Loren.McQuade@Loren.McQuade_Dev-VR on 2017/09/07 19:51:29 *pending*
[Dev-VR] Added OculusHMD_SceneViewExtension, PlayerPosition/PlayerOrientation values, FOculusHMD::GetRelativeEyePose cross-eyed madness (CL 3631541, 3631687)
Change 3632353 by Ryan.Vance
#jira UE-49468
Don't apply xr camera rotation on the player controller when not using xr tracking.
Change 3632735 by Keli.Hlodversson
Better fix for #jira UE-49413.
Revert oculus xr camera code and use that one can have more than one view extension registered instead.
Use GetPriority to have the OculusHMD view extension code execute after the default xr camera.
The xr camera subclass did not forward the calls to ISceneViewExtension to the parent, breaking various functionality such as late update.
Fixes a crash when entering VR pie twice, back to back.
Change 3632752 by Keli.Hlodversson
Applying change 3632592 by Loren.McQuade@Loren.McQuade_Dev-VR_Branch on 2017/09/08 02:08:22
[Dev-VR] Push //UE4/Partner-Oculus@3632591 #rb merge
//UE4/Partner-Oculus to //UE4/Dev-VR/...
Reverted OculusHMD_XRCamera changes, as that clas has been removed in the interim.
Change 3633211 by Mike.Beach
Backing out Oculus MotionController hiding that accidently got submitted - we decided not to adopt this change originally.
Change 3633315 by Jeff.Fisher
merge from main with dev-platform problem children
-expecting SDRBackBuffer stuff to be wrong.
Change 3634006 by Mike.Beach
Resurecting Oculus clip plane settings which got dropped in the IXR refactor.
#jira UE-49520
Change 3634639 by Keli.Hlodversson
Avoid include cycle
https://ec-01.epicgames.net/commander/link/jobStepDetails/jobSteps/68863219?stepName=UE4Editor%20Static%20Analysis%20Win64%20%28IncludeTool%29&jobId=7995809&jobName=UE4%20Dev-VR%20-%20CL%203632752%20-%20Nightly%20Build&tabGroup=diagnosticHeader&firstPage=1
Change 3634641 by Jeff.Fisher
UE-49535 Lighting is blown out when playing in VR Preview on Vive
-Need pixel format to be PF_B8G8R8A8 for vr, now the plugins all build their render target and use that format.
#review-3634623
Change 3634682 by Jeff.Fisher
IHeadMountedDisplay forward declarations needed.
Change 3634690 by Ryan.Vance
We can't override the screen percentage when rendering for stereo
#jira UE-49287
Change 3635970 by Keli.Hlodversson
#jira UE-49563 Crash while opening QA-Game Referencing SharedPointer.h
Verify that StereoRendering is valid before calling IsStereoEnabled()
Change 3635979 by Mike.Beach
CIS static analysis fix - checking a ptr for null before we use it.
#jira UE-49531
Change 3636059 by Mike.Beach
Fixing XR system name aliasing for the -hmd command.
[CL 3638830 by Ryan Vance in Main branch]
2017-09-12 11:27:30 -04:00
|
|
|
#include "IXRTrackingSystem.h"
|
2014-06-03 18:07:27 -04:00
|
|
|
|
|
|
|
|
/** The filter vertex declaration resource type. */
|
|
|
|
|
class FDistortionVertexDeclaration : public FRenderResource
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2014-06-03 18:07:27 -04:00
|
|
|
FVertexDeclarationRHIRef VertexDeclarationRHI;
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-06-03 18:07:27 -04:00
|
|
|
/** Destructor. */
|
|
|
|
|
virtual ~FDistortionVertexDeclaration() {}
|
|
|
|
|
|
2014-06-27 11:07:13 -04:00
|
|
|
virtual void InitRHI() override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-06-17 18:27:26 -04:00
|
|
|
uint16 Stride = sizeof(FDistortionVertex);
|
2014-06-03 18:07:27 -04:00
|
|
|
FVertexDeclarationElementList Elements;
|
2014-07-03 21:55:37 -04:00
|
|
|
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, Position),VET_Float2,0, Stride));
|
|
|
|
|
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, TexR), VET_Float2, 1, Stride));
|
|
|
|
|
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, TexG), VET_Float2, 2, Stride));
|
|
|
|
|
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, TexB), VET_Float2, 3, Stride));
|
|
|
|
|
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, VignetteFactor), VET_Float1, 4, Stride));
|
|
|
|
|
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, TimewarpFactor), VET_Float1, 5, Stride));
|
2019-02-15 18:52:44 -05:00
|
|
|
VertexDeclarationRHI = PipelineStateCache::GetOrCreateVertexDeclaration(Elements);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-06-27 11:07:13 -04:00
|
|
|
virtual void ReleaseRHI() override
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-06-03 18:07:27 -04:00
|
|
|
VertexDeclarationRHI.SafeRelease();
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-06-03 18:07:27 -04:00
|
|
|
/** The Distortion vertex declaration. */
|
|
|
|
|
TGlobalResource<FDistortionVertexDeclaration> GDistortionVertexDeclaration;
|
2014-04-23 17:26:59 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FHMDDistortionParameters, )
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputTexture)
|
|
|
|
|
SHADER_PARAMETER_SAMPLER(SamplerState, InputSampler)
|
2021-11-18 14:37:34 -05:00
|
|
|
SHADER_PARAMETER(FVector2f, EyeToSrcUVScale)
|
|
|
|
|
SHADER_PARAMETER(FVector2f, EyeToSrcUVOffset)
|
2019-10-01 13:03:04 -04:00
|
|
|
RENDER_TARGET_BINDING_SLOTS()
|
|
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
|
|
|
|
class FHMDDistortionPS : public FGlobalShader
|
2014-04-23 17:26:59 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
public:
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FHMDDistortionPS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FHMDDistortionPS, FGlobalShader);
|
|
|
|
|
using FParameters = FHMDDistortionParameters;
|
2014-07-03 21:55:37 -04:00
|
|
|
|
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3809756)
#rb None
#lockdown Nick.Penwarden
============================
MAJOR FEATURES & CHANGES
============================
Change 3629223 by Rolando.Caloca
DR - Rollback //UE4/Dev-Rendering/Engine/Source/Runtime/VulkanRHI to changelist 3627847
Change 3629708 by Rolando.Caloca
DR - vk - Redo some changes from DevMobile
3601439
3604186
3606672
3617383
3617474
3617483
Change 3761370 by Arne.Schober
DR - Added CityHash to use with conatiners and stuff. It provides good performance and high quallity across multiple platforms.
Change 3761437 by Guillaume.Abadie
Optimises motion blur compute shader for consoles.
Change 3761483 by Guillaume.Abadie
Fixes D3D11 RHI lying to dynamic resolution heuristic with t.MaxFPS.
Change 3761995 by Mark.Satterthwaite
Add the Metal compiler path to the local .pch filename to avoid problems when Xcode moves.
Change 3761996 by Mark.Satterthwaite
Emit more details when a pixel shader is found to have no outputs at all which Metal doesn't permit. More likely this is a bug in the shader compiler not configuring the in-out mask correctly...
#jira UE-52292
Change 3761999 by Mark.Satterthwaite
No need to avoid tessellation for FMetalRHICommandContext::RHIEndDrawIndexedPrimitiveUP anymore - that was from back when the tessellation logic was replicated in each RHI*Draw* implementation.
#jira UE-51937
Change 3762181 by Joe.Graf
Changed MaxShaderJobBatchSize to 25 on Mac as it reduced shader compile time by 21%
Change 3762607 by Mark.Satterthwaite
Remove accidentally included changes from 3761995.
Change 3762612 by Mark.Satterthwaite
Enable the explicit sincos intrinsic for Metal to avoid instances of UE-52477 that can cause shaders to compile incorrectly through hlslcc.
#jira UE-52477
Change 3762772 by Michael.Lentine
Move RHI calls to render thread.
Change 3763021 by Richard.Wallis
Remove shader cache tool project and implementation.
#jira UE-51613
Change 3763082 by Guillaume.Abadie
More SceneTexture, SceneColor and SceneDepth automated tests
Change 3763111 by Richard.Wallis
Clone of CL 3763033 (Release-4.18):
Fix for crash upon launching packaged game on Mac with Share Material Shader Code enabled.
#jira UE-52121
Change 3763657 by Michael.Lentine
Invalidate ddc for skeletal mesh render data so that the duplicated vertex render structures are properly serialized.
Change 3763727 by Jian.Ru
Fix Player Collision view mode. It is caused by checking an uninitialized vertex buffer so the check always fail.
#jira UE-52052
Change 3763738 by Guillaume.Abadie
Implements SSR input post process material location.
Change 3764271 by Mark.Satterthwaite
Allow ControlPointPatch lists to flow through MetalRHI as it was setup to handle this transparently - the VSHS compute shader will convert them to triangles to draw. Report the same warning as in the pipeline creation stage as this hasn't been formally validated.
#jira UE-52454
Change 3764316 by Daniel.Wright
Added AVolumetricLightmapDensityVolume - gives local control over Volumetric Lightmap density. Dropping the top mip outside of the play area in Monolith saves 20Mb (35Mb original).
Volumetric Lightmap no longer refines around static translucent geometry - saves 5Mb in Monolith
Reworked brick culling by error mechanism. Now compares error to interpolated parent lighting instead of the brick average - prevents dropping constant value bricks which are near a wall and cause leaking due to parent interpolation after being culled.
Change 3764318 by Daniel.Wright
Missing file
Change 3764321 by Daniel.Wright
Shader compiling memory optimizations
* Editor memory: Sharing uniform buffer includes and GeneratedInstancedStereo.ush per FShaderType (was previously duplicated per FShader job)
* SCW input size: Sharing uniform buffer includes and SharedEnvironment per batch
* 7.6Gb of shader job inputs in memory -> .5Gb (13x less) when doing a full shader compile of Paragon Editor
* 13.8Gb written into worker input files -> 2.9Gb (4.7x less). Global shaders are never batched when sent to SCW so unoptimized by these changes.
Change 3764595 by Daniel.Wright
Added VolumetricLightmapDensityVolume asset icons
Change 3764701 by Michael.Lentine
Add duplicated vertices merging for meshmerge.
Change 3766002 by Guillaume.Abadie
Fixes a crash in translucency.
Change 3766007 by Guillaume.Abadie
Oups.... Fixes compilation failure.
Change 3766697 by Guillaume.Abadie
Giant refactor of global shader interface for upcoming native support of permutation.
CL generated by python script.
Change 3767205 by Chris.Bunner
Deferring FMaterial::RenderingThreadShaderMap update to render-thread rather than assumption commands have been flushed.
#jira UE-50652
Change 3767207 by Chris.Bunner
Clamp fetched texture coordinates to those available on the mesh.
Change 3767209 by Chris.Bunner
PR #4203: Early-outs in UMaterialInstance parameter setters (Contributed by stefanzimecki)
#jira UE-52193
Change 3767772 by Mark.Satterthwaite
MetalShaderFormat will no longer fallback to text shaders when you ask it to compile to bytecode but the bytecode compiler is not available (either locally or remotely) - this ensures that the DDC can't be poisoned by incorrectly configured clients. The Editor is already setup such that if the remote shader compiler is not configured & Xcode is not available locally the shader-compiler will be invoked to generate text shaders.
#jira UE-52554
Change 3768604 by Guillaume.Abadie
Polish up with new global shader function signature.
Change 3768993 by Guillaume.Abadie
Fixes r.Upscale.Panini cvars
Change 3769478 by Mark.Satterthwaite
Move the ue4_stdlib.metal & PCH into a temporary directory that exists for the lifetime of the SCW on the remote side as well as the local one and add this path as an include directory.
#jira UE-52587
Change 3769703 by Mark.Satterthwaite
For all Metal platforms >= Metal v1.2 transform mul(a,b) into fma(a,b,0) to prevent the Apple compiler reordering operations differently between the base & depth passes which results in variance in the position output.
For iOS disable fast-math when the vertex-shader uses World-Position-Offset because there are additional problems on the iOS shader compiler that result in position variance even with the above fix - WPO performance will suffer but I don't have any alternatives.
Remove the depth-offset hack from the depth-only vertex shader again.
#jira UES-5651
Change 3769763 by Mark.Satterthwaite
Handle swizzle's in the hlslcc fma identification pass so that we reduce the number of instructions and the platform compiler can't break the instructions up.
Change 3769849 by Mark.Satterthwaite
Fix CIS error.
Change 3770517 by Richard.Wallis
Fix for crash when creating a new media texture (AppleIntelHD5000GraphicsMTLDriver!SamplerStage::bindSamplerToTexture()). Missing texture resource for binding. Old InitDynamicRHI() code has been refactored out into seperate functions which leaves us on Mac with a NULL resource initially after creation which Metal doesn't like. This fix puts InitDynamicRHI down the default setup/clear path which inits default resources - I don't think we should use a global dummy in this instance as this is a render target.
#jira UE-51940
Change 3770688 by Uriel.Doyon
Fixed texture resolution returning 0 when running blueprint construction scripts at cook time.
Change 3771115 by Mark.Satterthwaite
Report errors from failed attempts to compile global shaders or we can't see why things fail on non-Windows platforms.
Change 3771263 by Mark.Satterthwaite
Change the way ManualVertexFetch is enabled on Metal platforms so that it is enabled when targeting Metal v1.2 and higher (macOS 10.12+/iOS 10+). This brings iOS in the Desktop Forward renderer back into line with the Mac.
#jira UERNDR-300
Change 3773472 by Guillaume.Abadie
Fixes a crash on PIE of SimpleComposure project.
Change 3773475 by Guillaume.Abadie
Fixes bug in editor viewport caused by SSR input changes.
Change 3774677 by Arne.Schober
DR - Deprecated SetLocal from the RHICmdlist
Fixed some unnecessary PSO collisions.
Change 3777037 by Mark.Satterthwaite
Remove incorrect change that caused a reference to "accurate::sincos" to appear in some Metal shaders rather than "precise::sincos".
Change 3777122 by Mark.Satterthwaite
Back out changelist 3777037 - I'm blind and wasn't seeing the real problem was a stale shader cache...
Change 3777196 by Mark.Satterthwaite
Fix text-shader compilation on iOS 10 - maybe iOS 9 too (untested!).
We need our own make_scalar type-trait template for ue4_stdlib.metal so that we still compile with older iOS runtime compilers and we can't use as_type to directly implement the packHalf2x16/unpackHalf2x16 intrinsics for these older runtime compilers either.
Change 3779098 by Rolando.Caloca
DR - vk - Fix query index
Change 3779275 by Mark.Satterthwaite
Silence the Metal runtime compiler warning caused by use of a deprecated enum value when running text shaders compiled for Metal v1.0/1.1 on a Metal v1.2+ OS.
#jira UE-52554
Change 3779427 by Rolando.Caloca
DR - vk - Fix for allocator contention
Change 3779608 by Uriel.Doyon
Fixed invalid access in the resave package commantlet when building texture streaming material data for materials enabling tesselation.
Change 3784496 by Mark.Satterthwaite
Temporarily disable USE_OBJECT_COMPOSITING_TILE_CULLING for Metal shader compilation only - other platforms are unaffected - as it isn't working properly for some reason. need to work out what's up but don't want Distance Fields to be completely snookered in the interim.
#jira UE-52952
Change 3784608 by Rolando.Caloca
DR - Copy 3784588
- Fix for drivers returning out of date swapchains during resizes
Change 3784734 by Mark.Satterthwaite
Real fix for UE-52952 - MetalShaderFormat wasn't propagating the full thread-group value.
#jira UE-52952
Change 3784741 by Mark.Satterthwaite
More Metal debugging commandline options "-metalfastmath" & "-metalnofastmath" to force fast-math on or off for all shaders, must be using runtime-compiled shaders (i.e. -metalshaderdebug or r.Shaders.Optimise=0) to take effect.
Change 3787103 by Guillaume.Abadie
Kills BuiltinSamplers UB
Change 3787207 by Guillaume.Abadie
Sorry, compile fix that were fine with local changes...
Change 3787396 by Marcus.Wassmer
PR #4271: UE-52901: Set VIS_Max meta to hidden (Contributed by projectgheist)
Change 3788028 by Peter.Sumanaseni
Working linear HDR exr output from sequencer
Change 3788536 by Mark.Satterthwaite
Track whether the Metal shader uses the discard_fragment function as when this is used but without any other outputs we know we need to bind at least one render-target or a depth-stencil surface but we don't know which. This lets us correctly error when we encounter a shader with no outputs at all which Metal doesn't permit.
#jira UE-52292
Change 3788538 by Mark.Satterthwaite
Let's try mitigating UE-46604 on Nvidia by retaining resource references in the command-buffer. This shouldn't be necessary and isn't typically on other vendors but we haven't been able to reproduce this reliably enough to get to the bottom of it.
#jira UE-46604
Change 3789083 by Guillaume.Abadie
Implements global shader permutations. Example in ScreenSpaceReflections.cpp.
Change 3789090 by Guillaume.Abadie
Fixes linux build.
Change 3789106 by Guillaume.Abadie
Fixes compilation failure in niagara plugin.
Change 3789274 by Guillaume.Abadie
Avoid hit proxies to clobber TAA's hitsory.
#jira UE-52968
Change 3789380 by Guillaume.Abadie
Back out changelist 3789083: global shader permutation because compilation failure in clang.
Change 3789648 by Guillaume.Abadie
Relands global shader permutation, with clang support.
Change 3789712 by Guillaume.Abadie
Fixes TestImage show flag with TAAU on.
#jira UE-53061
Change 3791593 by Guillaume.Abadie
Reinvalidates shaders with shader permutations.
Change 3791884 by Daniel.Wright
Added BP setter for LowerHemisphereColor
Change 3791886 by Daniel.Wright
Added LightmapType to PrimitiveComponent
* ForceVolumetric allows forcing static geometry to use Volumetric Lightmaps, which can be useful on instanced foliage where seams are prevalent. Lightmass internal caching still requires lightmap UVs and reasonable lightmap resolution.
* ForceSurface replaces bLightAsIfStatic
Improvements to Volumetric Lightmap quality needed for static geometry
* Stationary light shadowing is now dilated inside geometry
* Now doing two dilation passes since samples near geometry see inside due to ray start bias
* Refinement around geometry uses an expanded cell bounds when the geometry is going to use Volumetric Lightmaps, since cross-resolution stitching causes leaking
Lightmass debug primitives are now tied to a swarm task instead of global - allows debugging of Volumetric Lightmap tasks
Change 3792256 by Guillaume.Abadie
Fixes a bug where permutation was not actually serialised in FShader, so was ending up recompiling shader at every load.
Change 3792884 by Marcus.Wassmer
Copying //UE4/Partner-AMD to Dev-Rendering (//UE4/Dev-Rendering)
Change 3793200 by Marcus.Wassmer
Copying //UE4/Partner-IDV-SpeedTree to Dev-Rendering (//UE4/Dev-Rendering)
Speedtree 8 support
Change 3793206 by Brian.Karis
Added color grading control BlueCorrection to correct for artifacts with "electric" blues due to the ACEScg color space. Bright blue desaturates instead of going to violet.
Added color grading control ExpandGamut which expands bright saturated colors outside the sRGB gamut to fake wide gamut rendering.
ACES changes.
Change 3793344 by Marcus.Wassmer
Fix editortest compile
Change 3794285 by Guillaume.Abadie
Serializes PermutationId according to archive rendering version to avoid issues with old material that were serializing a shader map into UObject.
Change 3794307 by Guillaume.Abadie
Resaves uassets that were modified between 3789648 and 3794285
Change 3794627 by Mark.Satterthwaite
Implement two components for MTLPP, an IMP cache for Objective-C selector implementations & an interposition framework for those same selectors:
- imp_SelectorCache & friends provide the IMP caching for each of the Metal protocols which constitute most of the API, so far I've not covered the Metal classes used for the various descriptor/initializer types. Each type has its own IMPTable which caches the selector's implementation pointer and provides the mechanism to hook that implementation. As Objective-C is runtime dynamic this look up must be performed on the actual Class value returned by an object at runtime - you can't do this at compile time. Even things like NSString which appear compile-time static are really not as NSString is an alias for a class-cluster (NSString, NSMutableString, __NSInlineString and more).
- The interpose directory contains MTI* files which are the framework for interposing all the functions in Metal's runtime API - I deliberately omit the descriptor classes & read-only functions as there's no benefit to interposing them - which I can build off to create a trace tool or a superior validation layer. Right now this is Mac only as there'll be some problems to solve for iOS/tvOS due to difference in linking requirements - not insurmountable.
- Rebuild MTLPP's implementation of the C++ wrapper classes around the IMPTable's - this means we avoid all the objc_msgSend overhead for all the classes and functions whose implementations are cached. Right now the IMPTable is going to incur a look-up for all non-copy/move constructors which is suboptimal - ideally the Metal IMPTables would be cached in the Device object as they will be consistent within a single Device.
- Sort out the MTLPP availability logic - it now exports the availability warnings to the caller and internally just blithely assumes it may call the functions, the caller is responsible for ensuring that calls are made only on appropriate devices & OSes. This reduces MTLPP complexity and better fits how MetalRHI works.
- Fix a number of retain/release bugs that were lying dormant in MTLPP but exposed by the switch to IMPTables.
- Add tvOS support.
Next up, put this into MetalRHI and start fixing all the fallout.
Change 3794631 by Mark.Satterthwaite
Missed updating mtlpp's build.cs for TVOS.
Change 3794651 by Uriel.Doyon
UPointLightComponent::GetUnitsConversionFactor() now takes the cone angle as parameter. This allows to fix spotlight unit conversion when using lumens.
Change 3794720 by Guillaume.Abadie
Fixes a bug in Global{Bilinear,Trilinear}ClampedSampler that was actually doing a Point sampling.
Change 3794749 by Mark.Satterthwaite
Fix mtlpp.build.cs paths.
Change 3794856 by Mark.Satterthwaite
Fix some shadowing warnings.
Change 3795484 by Daniel.Wright
Implemented the Spherical Harmonic windowing algorithm from 'Stupid Spherical Harmonics (SH) Tricks'
New WorldSettings Lightmass property VolumetricLightmapSphericalHarmonicSmoothing controls the global amount of smoothing applied
Change 3795590 by Brian.Karis
Area light fixes
Fixed order of operations. This helps mixing of SourceRadius, SourceLength, and SoftSourceRadius.
Change 3796832 by Marcus.Wassmer
Correct shouldcache condition for new resolve shader
Change 3796884 by Marcus.Wassmer
Doing it right this time.
Change 3797196 by Mark.Satterthwaite
More updates to MTLPP to make things simpler and reduce the number of spurious Objective-C warnings that are emitted because of the way we are using the runtime.
Change 3797200 by Daniel.Wright
Lightmass now uses the highest density VolumetricLightmapDensityVolume settings that affect any part of a cell
Change 3797221 by Daniel.Wright
Reduced default SphericalHarmonicSmoothing based on RoboRecall tests. Now only active with strong direct lighting from static lights by default.
Change 3797411 by Brian.Karis
Disable ExpandGamut for old tone mapper.
Change 3797462 by Mark.Satterthwaite
More build warnings silenced after changing to the lowest possible deployment target OS for each library.
Change 3797585 by Mark.Satterthwaite
Range-based-For support in the NSArray wrapper.
Change 3797836 by Mark.Satterthwaite
Even more forward-declarations to avoid system headers poking through to the including code from mtlpp.
Change 3798027 by Mark.Satterthwaite
Fix handling of nil objects, on which no functions may be called, command-buffer retention and IMP declaration.
Change 3798154 by Mark.Satterthwaite
Fix some egregious memory leaks that rewriting to use mtlpp exposed before we carry on - don't want these slipping into 4.19.
Change 3800990 by Mark.Satterthwaite
Typedef all the completion-handler callback types in mtlpp to make future me's life easier.
Change 3801400 by Chris.Bunner
Improving automated test errors on failure to generate report data.
Change 3801726 by Mark.Satterthwaite
Correct some function availability and the command-buffer error status in mtlpp.
Change 3801808 by Chris.Bunner
Added DefaultScalability.ini to EngineTest that forces all quality levels to Engine default Epic for now to improve consistency.
Change 3801862 by Marcus.Wassmer
Update automated tests with color gamut change
Change 3802214 by Chris.Bunner
When running automated tests in and editor-locked PIE viewport, skip resizing as the editor can't handle this.
Added bindable delegate called when ScreenshotRequest is processed - Useful to allow screenshots to override and restore settings per capture.
#jira UE-53188
Change 3802243 by Chris.Bunner
Added button to automated test screenshot browser to add or replace all outstanding test reports if appropriate.
DeleteAllReports button is now only enabled whilst there are reports in the list.
Change 3802372 by Chris.Bunner
Updating more test screenshots.
Change 3803683 by Chris.Bunner
Adding more logging and multiple attempts to automated test report network save.
Added small wait on repeated operations that are known to fail.
Change 3803826 by Rolando.Caloca
DR - vk - Fix merge issue
Change 3804181 by Chris.Bunner
Tentative fix for CIS test failure.
Change 3804236 by Chris.Bunner
Additional logging for case where file write silently fails, report platform-specific error.
Change 3804303 by zachary.wilson
Cleaning up assets in QAGame saved with empty engine versions to resolve warnings seen when launching on
Change 3804410 by Chris.Bunner
Added additional logging when automated screenshot test fails due to size mismatch.
Mismatched bounds are colored red in the delta.
Change 3804455 by Mark.Satterthwaite
Fix a small number of persistent memory leaks on the Mac build that slowly consume more and more memory as you use the Editor - interacting with menu's was particularly egregious as each NSMenu would leak after you move away.
#jira NA
Change 3804667 by Chris.Bunner
Speculative CIS fixes.
Change 3806008 by Chris.Bunner
Partially reimplementing backed-out CL 3804181 to improve consistency of how automated screenshot test settings are applied/restored.
#tests CIS preflight job 8174412
Change 3806909 by Mark.Satterthwaite
Use the vertex-shader's in-out mask to ensure that we only validate legitmate vertex-streams in Metal's DrawIndexedPrimitive implementation.
#jira UE-53046
Change 3807059 by laz.matech
Checking in QAGame Rendering Map, QA-PhysicalLightingUnits, for testing Physical Light Units.
Wanted to get this in before copy up.
#Jira none
Change 3807726 by Chris.Bunner
Removed a check that we can't fix up. The check hits unbound buffers which it assumes means a failure but is actually due to m.v.fetch. We don't have the information available to know which are which removed from the input without reading from the shader.
#jira UE-53046
Change 3807800 by Guillaume.Abadie
Fixes some warning in shader headers.
Change 3807804 by Guillaume.Abadie
Back out changelist 3807800
Change 3807807 by Guillaume.Abadie
Relands shader header warnings.
Change 3808046 by Chris.Bunner
Dropping a new automated test error back to a warning as this may lead to genuine issues being ignored in the short term.
Change 3809579 by Chris.Bunner
Back out changelist 3774677.
#jira UE-53483
Change 3809620 by Chris.Bunner
Updating animated cloth test screenshot.
Change 3803629 by Chris.Bunner
Rebuilt CornellBox and DistanceField test maps, updated screenshots.
Change 3787045 by Guillaume.Abadie
Moves some global samplers to Common.ush
Change 3809756 by Chris.Bunner
Updating animated cloth test screenshot.
[CL 3809764 by Chris Bunner in Main branch]
2017-12-15 12:47:47 -05:00
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
2014-04-23 17:26:59 -04:00
|
|
|
{
|
2014-06-17 20:12:54 -04:00
|
|
|
return true;
|
2014-04-23 17:26:59 -04:00
|
|
|
}
|
2019-10-01 13:03:04 -04:00
|
|
|
};
|
2014-04-23 17:26:59 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
IMPLEMENT_GLOBAL_SHADER(FHMDDistortionPS, "/Engine/Private/PostProcessHMD.usf", "MainPS", SF_Pixel);
|
2014-04-23 17:26:59 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
class FHMDDistortionVS : public FGlobalShader
|
|
|
|
|
{
|
2014-04-23 17:26:59 -04:00
|
|
|
public:
|
2019-10-01 13:03:04 -04:00
|
|
|
DECLARE_GLOBAL_SHADER(FHMDDistortionVS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FHMDDistortionVS, FGlobalShader);
|
|
|
|
|
using FParameters = FHMDDistortionParameters;
|
2014-04-23 17:26:59 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
2014-04-23 17:26:59 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FHMDDistortionVS, "/Engine/Private/PostProcessHMD.usf", "MainVS", SF_Vertex);
|
|
|
|
|
|
|
|
|
|
FScreenPassTexture AddDefaultHMDDistortionPass(FRDGBuilder& GraphBuilder, const FViewInfo& View, const FHMDDistortionInputs& Inputs)
|
|
|
|
|
{
|
|
|
|
|
check(Inputs.SceneColor.IsValid());
|
|
|
|
|
|
|
|
|
|
FScreenPassRenderTarget Output = Inputs.OverrideOutput;
|
|
|
|
|
|
|
|
|
|
if (!Output.IsValid())
|
|
|
|
|
{
|
|
|
|
|
Output = FScreenPassRenderTarget::CreateFromInput(GraphBuilder, Inputs.SceneColor, ERenderTargetLoadAction::EClear, TEXT("HMD Distortion"));
|
2014-06-03 18:07:27 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
FHMDDistortionParameters* PassParameters = GraphBuilder.AllocParameters<FHMDDistortionParameters>();
|
|
|
|
|
PassParameters->RenderTargets[0] = Output.GetRenderTargetBinding();
|
|
|
|
|
PassParameters->InputTexture = Inputs.SceneColor.Texture;
|
|
|
|
|
PassParameters->InputSampler = TStaticSamplerState<SF_Bilinear, AM_Border, AM_Border, AM_Border>::GetRHI();
|
|
|
|
|
|
|
|
|
|
check(GEngine->XRSystem.IsValid() && GEngine->XRSystem->GetHMDDevice());
|
|
|
|
|
IHeadMountedDisplay* HMDDevice = GEngine->XRSystem->GetHMDDevice();
|
|
|
|
|
|
2014-06-03 18:07:27 -04:00
|
|
|
{
|
2020-10-20 11:36:46 -04:00
|
|
|
FHeadMountedDisplayPassContext PassContext(GraphBuilder.RHICmdList, View);
|
2014-06-03 18:07:27 -04:00
|
|
|
FVector2D EyeToSrcUVScaleValue;
|
|
|
|
|
FVector2D EyeToSrcUVOffsetValue;
|
2019-10-01 13:03:04 -04:00
|
|
|
HMDDevice->GetEyeRenderParams_RenderThread(PassContext, EyeToSrcUVScaleValue, EyeToSrcUVOffsetValue);
|
2022-02-02 01:43:41 -05:00
|
|
|
PassParameters->EyeToSrcUVScale = FVector2f(EyeToSrcUVScaleValue); // LWC_TODO: Precision loss
|
|
|
|
|
PassParameters->EyeToSrcUVOffset = FVector2f(EyeToSrcUVOffsetValue); // LWC_TODO: Precision loss
|
2014-06-03 18:07:27 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
TShaderMapRef<FHMDDistortionVS> VertexShader(View.ShaderMap);
|
|
|
|
|
TShaderMapRef<FHMDDistortionPS> PixelShader(View.ShaderMap);
|
|
|
|
|
|
|
|
|
|
const FIntRect OutputViewRect(Output.ViewRect);
|
|
|
|
|
|
|
|
|
|
GraphBuilder.AddPass(
|
|
|
|
|
RDG_EVENT_NAME("HMDDistortion"),
|
|
|
|
|
PassParameters,
|
|
|
|
|
ERDGPassFlags::Raster,
|
|
|
|
|
[VertexShader, PixelShader, PassParameters, OutputViewRect, &View, HMDDevice](FRHICommandListImmediate& RHICmdList)
|
2014-06-03 18:07:27 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
RHICmdList.SetViewport(OutputViewRect.Min.X, OutputViewRect.Min.Y, 0.0f, OutputViewRect.Max.X, OutputViewRect.Max.Y, 1.0f);
|
2014-04-23 17:26:59 -04:00
|
|
|
|
2020-02-06 13:13:41 -05:00
|
|
|
FScreenPassPipelineState PipelineState(VertexShader,PixelShader);
|
2019-11-18 12:56:06 -05:00
|
|
|
PipelineState.VertexDeclaration = GDistortionVertexDeclaration.VertexDeclarationRHI;
|
|
|
|
|
SetScreenPassPipelineState(RHICmdList, PipelineState);
|
2014-07-03 21:55:37 -04:00
|
|
|
|
2020-02-06 13:13:41 -05:00
|
|
|
SetShaderParameters(RHICmdList, VertexShader, VertexShader.GetVertexShader(), *PassParameters);
|
|
|
|
|
SetShaderParameters(RHICmdList, PixelShader, PixelShader.GetPixelShader(), *PassParameters);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2020-10-20 11:36:46 -04:00
|
|
|
FHeadMountedDisplayPassContext PassContext(RHICmdList, View);
|
2019-10-01 13:03:04 -04:00
|
|
|
HMDDevice->DrawDistortionMesh_RenderThread(PassContext, PassParameters->InputTexture->Desc.Extent);
|
|
|
|
|
});
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
return MoveTemp(Output);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
FScreenPassTexture AddHMDDistortionPass(FRDGBuilder& GraphBuilder, const FViewInfo& View, const FHMDDistortionInputs& Inputs)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
check(GEngine && GEngine->XRSystem.IsValid());
|
|
|
|
|
checkf(GEngine->XRSystem->GetHMDDevice(), TEXT("EngineShowFlags.HMDDistortion can not be true when IXRTrackingSystem::GetHMDDevice returns null"));
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
// First attempt to use a pass from the HMD system.
|
2019-10-11 15:33:31 -04:00
|
|
|
FScreenPassTexture Output;
|
|
|
|
|
GEngine->XRSystem->GetHMDDevice()->CreateHMDPostProcessPass_RenderThread(GraphBuilder, View, Inputs, Output);
|
2019-10-01 13:03:04 -04:00
|
|
|
|
|
|
|
|
if (!Output.IsValid())
|
2018-05-31 18:19:49 -04:00
|
|
|
{
|
2019-10-01 13:03:04 -04:00
|
|
|
Output = AddDefaultHMDDistortionPass(GraphBuilder, View, Inputs);
|
2018-05-31 18:19:49 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-01 13:03:04 -04:00
|
|
|
return Output;
|
|
|
|
|
}
|