You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3148067 on 2016/10/01 by Daniel.Wright Support for ReflectionEnvironment and light type show flags with ForwardShading Change 3149085 on 2016/10/03 by Daniel.Wright Support for ReflectionEnvironment show flag in base pass reflections without any shader overhead Change 3162206 on 2016/10/13 by Chris.Bunner Merging Dev-MaterialLayers to Dev-Rendering, CL 3161593: Material expressions; Trig, fast-trig, saturate, round, truncate, pre-skinned normal. Added CustomEyeTangent to material attributes. Resolved some hard-coded attribute typing and other minor fixes. Change 3186067 on 2016/11/03 by Daniel.Wright Updated Stationary primitive tooltip to indicate that it allows the primitive to be changed, but not moved Change3186069on 2016/11/03 by Daniel.Wright Using a weighted geometric mean to combine multiple Distance Field Indirect Shadows, greatly reduces over-occlusion when overlap is high Change 3186084 on 2016/11/03 by Mark.Satterthwaite Duplicate 3172511: Don't set Metal resource option fields on texture descriptors when running on an OS that doesn't support them. #jira UE-37481 Change 3186089 on 2016/11/03 by Mark.Satterthwaite Duplicate CL #3169764: Fixed automatic conversion of G8_sRGB into RGBA8_sRGB required for Mac Metal, which fixes FORT-27627. #jira FORT-27627 Change 3186113 on 2016/11/03 by Mark.Satterthwaite Duplicate CL #3183807: Change the way we access the Metal viewport's backbuffer, to reduce possible causes of FORT-31649: - Added console variable "rhi.Metal.SupportsIntermediateBackBuffer" to control whether to use an extra render-target so we can support screenshots & movie capture, or render directly to the back-buffer to save memory & GPU performance. Still defaults to ON for Mac & OFF for iOS/tvOS. - Change the way we handle updates to the back-buffer size to ensure that the different threads access their intended version. #jira FORT-31649 Change 3186116 on 2016/11/03 by Mark.Satterthwaite Duplicate CL #3183823: Record Metal resource & state objects used in a command-buffer when rhi.Metal.RuntimeDebugLevel is set to 3 or higher. The object labels, types & descriptions will be printed on failure - if the object is deleted prior to this then we have a lifetime error and it will crash at this point and can be debugged further using our -metalretainrefs command-line option or Xcode's zombie-objects. Used to verify that FORT-31649 is not a simple resource lifetime error and thereby speed up Apple/vendor investigations. #jira FORT-31649 Change 3186818 on 2016/11/04 by Chris.Bunner PR #2907 Export UMaterialExpressionNoise (contributed by kayosiii). Change 3186979 on 2016/11/04 by Rolando.Caloca DR - Misc minor cleanup Change 3187169 on 2016/11/04 by Uriel.Doyon Incremental insertion of level data between PostLoad and AddToWorld Change 3187205 on 2016/11/04 by Mark.Satterthwaite Compile fixes for iOS. Change 3187389 on 2016/11/04 by Uriel.Doyon Fix for possible stall when loading hidden level Change 3187598 on 2016/11/04 by Michael.Trepka MetalViewport compile fix Change 3187678 on 2016/11/04 by Uriel.Doyon Fix for landscape grass textures not being streamed in correctly. Change 3187731 on 2016/11/04 by Rolando.Caloca DR - Start making type safe some cross compiler enums Change 3187824 on 2016/11/04 by Rolando.Caloca DR - clang compile fix Change 3187953 on 2016/11/04 by Rolando.Caloca DR - vk - Mac compile fix Change 3188696 on 2016/11/07 by Mark.Satterthwaite Another iOS compile fix for new MetalViewport validation code. Change 3188906 on 2016/11/07 by Rolando.Caloca DR - Show permutation of LUTBlender Change 3189094 on 2016/11/07 by Chris.Bunner Fix RemoveAAJitter from projection matrix. #jira UE-37701, UE-38003 Change 3189134 on 2016/11/07 by Daniel.Wright Fix for CreateRenderTarget2D called in construction script during cooking Change 3189145 on 2016/11/07 by Chris.Bunner Follow-up to CL 3186818, export UMaterialExpressionVectorNoise. Change 3189239 on 2016/11/07 by Daniel.Wright Added show flag for Contact Shadows, disabled in planar reflections Change 3189252 on 2016/11/07 by Daniel.Wright Support for Reflection Capture intensity with simple reflections, which are the default with Forward Shading Change 3189406 on 2016/11/07 by Mark.Satterthwaite Really fix the last of the iOS compile errors from changes to the MetalViewport code. Change 3190854 on 2016/11/08 by Ben.Woodhouse XB1: Fix memory corruption with RHICreateVertexBuffer and RHICreateIndexBuffer when using initial data (Procedural Mesh Component crash) #jira UE-34264 #fyi james.golding #fyi keith.judge Change 3190962 on 2016/11/08 by Olaf.Piesche Unshelved from pending changelist '3176615' - Gil's fix for race condiiton with particle vertex factory reuse across different passes; potential to fix a number of issues Change 3191959 on 2016/11/09 by Uriel.Doyon Removed some static primitives from the dynamic primitive handler for texture streaming. Change 3193122 on 2016/11/10 by Chris.Bunner Always update non-preview material resources for use in code preview. #jira UE-38223 Change 3193190 on 2016/11/10 by Gil.Gribb UE4 - Fixed rare bug with shadow groups rendering things that have not been setup to render this frame. #jira UE-36379 Change 3193523 on 2016/11/10 by Uriel.Doyon Fixed incorrect section bounds used for texture streaming. Change 3193962 on 2016/11/10 by Uriel.Doyon Added defrag of dynamic bounds used for the texture streaming. Allows to remove unused bounds over time. Change 3193974 on 2016/11/10 by Uriel.Doyon New "Required Texture Resolution" view mode. Showing the ratio between the currently streamed texture resolution and the resolution wanted by the GPU. Change 3194109 on 2016/11/10 by Uriel.Doyon Another patch on material bounds used for texture streaming. Change 3194665 on 2016/11/11 by Chris.Bunner Duplicated behavior for inherited velocity scaling scaling to vert/surface spawned particles. Change 3194734 on 2016/11/11 by Rolando.Caloca DR - vk - Simplified some texture casting Change 3194867 on 2016/11/11 by Rolando.Caloca DR - vk - SM5 fixes Change 3195176 on 2016/11/11 by Chris.Bunner Fixed incorrectly updated NVAPI error. Change 3195425 on 2016/11/11 by Uriel.Doyon Fixed possible invalid level reference in the texture streamer Change 3196512 on 2016/11/14 by Gil.Gribb Merging //UE4/Dev-Main@3196156 to Dev-Rendering (//UE4/Dev-Rendering) Change 3196750 on 2016/11/14 by Marcus.Wassmer Fix ordering problem with GPU cache transitions Change 3196815 on 2016/11/14 by Daniel.Wright Suppressed 'Instanced stereo rendering is not supported' warning showing up in CIS Change 3196818 on 2016/11/14 by Daniel.Wright Fixed FIndirectLightingCache::UpdateCachePrimitivesInternal churning through a bunch of temporary memory Change 3196819 on 2016/11/14 by Daniel.Wright Volume lighting samples are allowed outside of the importance volume if their influence affects the volume. Fixes black indirect lighting on movable components in maps with small importance volumes. Volume lighting samples placed on surfaces use a radius that covers the layer height spacing, which prevents an uncovered region between layers Change 3197243 on 2016/11/14 by Uriel.Doyon Async Task For Updating static component LastRender time #jira UE-24268 Change 3197359 on 2016/11/14 by Daniel.Wright Added Inscattering Texture controls to ExponentialHeightFog * When InscatteringColorCubemap is specified, directional light inscattering is disabled * Lerps betwen 1x1 mip at NonDirectionalInscatteringColorDistance to mip 0 at FullyDirectionalInscatteringColorDistance * Added FogCutoffDistance, so artists can prevent fog on skyboxes (requires fog to be setup matching the fog that was rendered into the sky texture so that distant mountains match) * Fog shader permutations based on what feature is enabled Change 3198419 on 2016/11/15 by Chris.Bunner PS4 HDR: Runtime toggle (backbuffer recreation on resize matching), UI composition. Matches PC behavior and controls. HDR: Generalized buffer formats, cvar consistency pass, LUT for UI composition, refactoring common functions. Exposed RHICreateTargetableShaderResource3D. Moved some (translucent) volume rendering helpers to allow access in Slate. Change 3198822 on 2016/11/15 by Daniel.Wright Mac compile fix Change 3199509 on 2016/11/15 by Uriel.Doyon Added support for viewmode param asset name (and note just param value). Used to investigate texture streamer behavior. Change 3199578 on 2016/11/15 by Rolando.Caloca DR - Add some shader resource tables to SCW when running with -directcompile Change 3199698 on 2016/11/15 by Rolando.Caloca DR - vk - Refactor shader & descriptor bindings Change 3199712 on 2016/11/15 by Rolando.Caloca DR - vk - r.Vulkan.StripGlsl to always strip glsl at runtime to save memory per shader Change 3199717 on 2016/11/15 by Rolando.Caloca DR - vk - Show hitching PSO info again Change 3199750 on 2016/11/15 by Rolando.Caloca DR - SCW clang compile fixes Change 3200353 on 2016/11/16 by Rolando.Caloca DR - vk - Mac fix Change 3200358 on 2016/11/16 by Chris.Bunner Only allow UI composition on platforms we currently use it. Change 3200823 on 2016/11/16 by Chris.Bunner Remove expression key attribute ID when not translating an attribute output to allow intended expression sharing. #jira UE-38699 Change 3200947 on 2016/11/16 by Mark.Satterthwaite Fix UE-38695 by not trying to resize the viewport on the wrong thread. #jira UE-38695 Change 3201069 on 2016/11/16 by Daniel.Wright Fog inscattering texture limited to SM4 and above, fixes ES2 compile errors Change 3201346 on 2016/11/16 by Brian.Karis Temporal AA fix for correct edge gradients. Filtering now combined with importance sampling. Enabled Catmull-Rom resolve filter. Results are now slightly sharper. Fixed antighosting. Will yet require a dilation to be perfect. Optimized bicubic filtering to 5 taps instead of 9. Cleaned out unused code. Change 3201369 on 2016/11/16 by Brian.Karis Bicubic texture sample Change 3201522 on 2016/11/16 by Rolando.Caloca DR - vk - Fix static analysis issues Change 3201878 on 2016/11/17 by Chris.Bunner Temporarily disable Nvapi HDR error logging. #jira UE-38529 Change 3202108 on 2016/11/17 by Simon.Tovey Assets with easy repro for flickering particles bug Change 3202181 on 2016/11/17 by Rolando.Caloca DR - vk - CIS android fix Change 3202325 on 2016/11/17 by Ben.Woodhouse Integrate 4.14.1 fix from 14 //UE4/Release-4.14 (@3201850) Fix CreateVertexbuffer and CreateIndexBuffer memory corruption (Procedural Mesh Component crash) #jira UE-34264 Change 3204394 on 2016/11/18 by Guillaume.Abadie PR #2808: AlphaComposite Fog Opacity fix (Contributed by moritz-wundke) #br Ben.Woodhouse Change 3204428 on 2016/11/18 by Guillaume.Abadie Fixes a couple of issues in decals: * Crash in FDecalDrawingPolicyFactory::DrawMesh() * ActorPostion material expression * PixelNormalWS material expression * Missing renaming from DEFERRED_DECAL to DECAL_PRIMITIVE #jira UE-38327, UE-38158, UE-37818, UE-37350 Change 3204429 on 2016/11/18 by Uriel.Doyon Darker default undefined accuracy. Reenabled the texture streaming build in the build all. Change 3204458 on 2016/11/18 by Chris.Bunner Shader truncation warnings fix. Change 3204459 on 2016/11/18 by Chris.Bunner Engine 'Passthrough' material fuction fix. V4 is now actually a V4. Change 3204460 on 2016/11/18 by Chris.Bunner Correctly handle some known Nvapi warnings. #jira UE-38529 Change 3204653 on 2016/11/18 by Marc.Olano Helper functions for tiled textures Checking in for Ryan Brucks Change 3204863 on 2016/11/18 by Arne.Schober DR - Replaced ENQUEUE_UNIQUE_RENDER_COMMAND with a Debuggable template Implementation Change 3204939 on 2016/11/18 by Arne.Schober DR - Make clang happy Change 3204968 on 2016/11/18 by Arne.Schober DR - UE-38494 - Fixed SpeedTree Wind crash, when force deleting the Asset. Change 3206293 on 2016/11/21 by Uriel.Doyon New member bHasStreamingUpdatePending in UTexture2D to delay update of global distance fields. Set to true when the streamer can possibly load a mip in the near future. #jira UE-37787 Change 3206551 on 2016/11/21 by Chris.Bunner Added material update context when forcing all shaders to recompile. #jira UE-38481 Change 3206644 on 2016/11/21 by Benjamin.Hyder Updating Planar Reflection example in TM-Shadermodels. Change 3206899 on 2016/11/21 by Rolando.Caloca DR - vk - SM5 fixes Change 3206900 on 2016/11/21 by Rolando.Caloca DR - Added missing strings for shader formats Change 3206983 on 2016/11/21 by Rolando.Caloca DR - vk - Support for SV_Coverage Change 3207237 on 2016/11/22 by Simon.Tovey Exporting particle module base and a couple of child classes as it's commonly requested. #test compiles Change 3207241 on 2016/11/22 by Gil.Gribb Merging //UE4/Dev-Main@3206998 to Dev-Rendering (//UE4/Dev-Rendering) Change 3207520 on 2016/11/22 by Ben.Woodhouse Cherry picked from //Fortnite/Main@3206301 Fixed GPU hang in Zone Map view. Was an issue with RenderThread using the device context without appropriate RHIThread flushes. #jira FORT-31616 #code_review keith.judge Change 3207541 on 2016/11/22 by Ben.Woodhouse Cherry picked from //fortnite/Main@3207422 * Fix UpdateTexture3D to create a staging texture of the region to update rather than the whole texture. This prevents distance fields crashing during update (allocating 18GB per frame in some cases) * Put UpdateTexture2D DMA support onto a cvar, disabled by default (corruption issues reported by licensees, plus not sure it's actually faster - could be slower due to reduced bandwidth; issues reported by licensees) * Fix UpdateTexture2D to only create a staging texture of the region to update, saving memory #jira UE-38609 Change 3207654 on 2016/11/22 by Chris.Bunner Don't flag 16-bit PNG/JPG textures as sRGB on import. #jira UE-30279 Change 3208434 on 2016/11/22 by Rolando.Caloca DR - vk - UAV transitions Change 3208490 on 2016/11/22 by Chris.Bunner Break material code sharing when we detect an unresolvable loop. By default change IsResultMA loop detection to stop on functions as we can determine type definitively. Unified IsResultMA detection across switch nodes. Change 3208860 on 2016/11/23 by Rolando.Caloca DR - vk - Fix some format issues Change 3209265 on 2016/11/23 by Arne.Schober DR - originally unshelved from 3153924 - Made Depth and Velocity Rendering Passes to use PSO only RHI interface, We are now passing down two structs that collect all the necessary information for the drawing policies to construct a PSO object. One during construction of the Policy, which contains information abouyt the CullMode, FillMode and PrimType. And another during rendering that passes infomation like BlendState and DepthStencilState down to the low levelrenderer into SetSharedState. Performance of the static drawlist ist slightly slower (less than 0.1ms on Consoles) due to some addtional branches and copies. The branches in the FDrawingPolicyRenderState will go away as soon as everything is converted to use the PSO interface. Performace of the GPU is slightly better due to less context rolls (mainly CullMode sorts in differently now) Change 3209305 on 2016/11/23 by Guillaume.Abadie Fix contact shadow's assemption on objects thickness Change 3209334 on 2016/11/23 by Brian.Karis Fixed TAA handling of alpha. Switched the meaning of AA_ALPHA to make sense. Change 3209903 on 2016/11/24 by Guillaume.Abadie Cherry picks alpha through post processing changelists 3201959, 3204143 and 3209883 from //UE4/Private-Partner-NREAL Change 3209973 on 2016/11/24 by Ben.Woodhouse Fix D3D11 and 12 static analysis warnings reported by Rob Troughton of Coconut Lizard (http://coconutlizard.co.uk/blog/ue4/pvs-studio-part5/) Change 3210023 on 2016/11/24 by Uriel.Doyon Fixed an issue with DropDetail when FixedFrameRate was set to a value smaller than MinDesiredFrameRate. #jira UE-37210 Change 3210026 on 2016/11/24 by Ben.Woodhouse Disable renderthread hang detection if a debugger is present, so we can debug the renderthread without crashing Change 3210049 on 2016/11/24 by Ben.Woodhouse Fix mac build Change 3210071 on 2016/11/24 by Uriel.Doyon Fixed an issue with masked materials and shader complexity viewmode when DBuffer Decals are enabled. #jira UE-37542 Change 3210374 on 2016/11/25 by Ben.Woodhouse * Fix issues with fast cleared dbuffer targets not being resolved when no decals are in the scene. This caused graphical corruption on XB1 and ensure failures on PS4 (with RHIThread disabled) * Move Decal rendertarget manager function implementations out of the header. #jira UE-38879 Change 3210390 on 2016/11/25 by Uriel.Doyon Fixed cubemap resourcesize not taking into account mipgen settings #jira UE-37045 Change 3210407 on 2016/11/25 by Uriel.Doyon "resavepackages" commandlet now supports -buildtexturestreaming that rebuilds the map texture streaming data. That can be used in combination with -buildlighting. Change 3210563 on 2016/11/27 by Rolando.Caloca DR - vk - Integrate cached memory fixes and PF_D24 format fix #jira UE-39025 PR #2974 Change 3210564 on 2016/11/27 by Rolando.Caloca DR - Fix for GL linker PR #2975 #jira UE-39029 Change 3210592 on 2016/11/27 by Rolando.Caloca DR - vk - SM5 fixes Change 3210597 on 2016/11/27 by Rolando.Caloca DR - vk - Prep for staging UB copies to GPU memory Change 3210600 on 2016/11/27 by Rolando.Caloca DR - vk - Extract generic range code Change 3210613 on 2016/11/27 by Rolando.Caloca DR - vk - Added r.Vulkan.SubmitOnDispatch Change 3211054 on 2016/11/28 by Rolando.Caloca DR - vk - Missing reference Change 3211330 on 2016/11/28 by Chris.Bunner Shader compile error for max texture coordinate count on skinned meshes. Change 3211384 on 2016/11/28 by Arne.Schober DR - Enforce move on EnqueueRenderCommand Lambda Change 3211431 on 2016/11/28 by Gil.Gribb Merging //UE4/Dev-Main@3211016 to Dev-Rendering (//UE4/Dev-Rendering) Change 3211738 on 2016/11/28 by Gil.Gribb IWYU fixes after merge Change 3212231 on 2016/11/28 by Richard.Wallis Fix build errors Change 3212253 on 2016/11/28 by Richard.Wallis Remove MacGraphicsSwitching plugin. #jira UE-37640 Change 3212310 on 2016/11/28 by Rolando.Caloca DR - vk - Update glslang to 1.0.33.0 Change 3212446 on 2016/11/28 by Guillaume.Abadie Implements PreviousFrameSwitch material expression Change 3212594 on 2016/11/28 by Arne.Schober DR - Fix missing include Change 3212681 on 2016/11/29 by Rolando.Caloca DR - vk - Auto flush for compute shader Change 3213000 on 2016/11/29 by Gil.Gribb temp fix for PF_MAX Change 3213161 on 2016/11/29 by Ben.Woodhouse Integrate latest D3D12 changes from //depot/Partners/Microsoft/UE4-DX12/...@3211714 Using: - p4 integrate //depot/Partners/Microsoft/UE4-DX12/Engine/Source/Runtime/D3D12RHI/...@3211714 //UE4/Dev-Rendering/Engine/Source/Runtime/D3D12RHI/... - p4 integrate //depot/Partners/Microsoft/UE4-DX12/Engine/Source/ThirdParty/Windows/DirectX/...@3211714 //UE4/Dev-Rendering/Engine/Source/ThirdParty/Windows/DirectX/... - p4 integrate //depot/Partners/Microsoft/UE4-DX12/Engine/Source/Programs/UnrealBuildTool/...@3211714 //UE4/Dev-Rendering/Engine/Source/Programs/UnrealBuildTool/... Changes from UE4-DX12: *** CL 3183818 *** Update D3D12 RHI to 4.14: - Merged changes from Epic up until 10/20/16 - Fixed an issue where command allocators where resetting too early. I changed to aggressive command list batching by default now that more SubmitCommandListHint calls exist in the upper engine, we don't need to worry about starving the GPU. Fewer ExecuteCommandLists calls means better performance and fewer Signals() so this change provides a GPU perf win. I had to fix an issue with aggressive batching where we would sometimes hold on to a command list long enough (in the pending list) but hadn't executed it yet. The command allocator was being put back in the queue of allocators during ReleaseCommandAllocator() without a syncpoint set and was thus being reset too early. I added a simple counter to the command allocator so it could track how many command lists were using it. It doesn't need to be thread safe since only one thread uses a command allocator at a time. I also added some stats around the # command lists and # command allocators since it would be possible to leak command allocators now if it's pending command list count isn't decremented correctly. In that case we'd keep creating new command allocators and eventually run out of memory. -Remove clear during allocate in the FD3D12FastConstantAllocator and FD3D12FastAllocator. The supplied resource locations are assumed to be new and thus don't need to be cleared. -Cleanup D3D12RHI stats. There were some unused stats as well as some missing ones. -Mark shader resource table uniform buffers as dirty only when the shader changes. Cleanup SetComputeShader calls and Dispatch calls to not set/unset the CS for each Dispatch. -Remove unused Check SRV resolved code that epic added to the D3D11 RHI and was brought over. We dont need it and we won't use this. -Remove "always on" cycle counters for high frequency RHI methods like RHISetShaderTexture. These should use the engine's stat macros as they are removed on TEST + SHIPPING builds. On Xbox a significant amount of CPU time is spent in things like QueryPerformanceCounter even when STATS aren't enabled. Currently 1% of an entire capture on XBOX is spent inside this call. I improved and cleaned up high freqency call stacks like: - RHISetShaderTexture - RHISetShaderResourceViewParameter - RHISetShaderParameter - RHISetUAVParameter In general I moved to use templated functions, removed unused parameters, unnecessary copies, etc. -Change D3D12 PIX profiling enable/disable to match Xbox and handle logic in the UEBuildWindows.cs for UBT. Also add a static assert to inform the developer when PIX profiling is requested but the engine is compiling out draw events. -Resources should be associated with the rendering thread's frame that it's currently recording command lists for and they shouldnt be cleaned up until those command lists have been translated to D3D12 command lists on the RHI thread AND completed executing on the GPU. This was confirmed to resolve an issue where CBV resources were being released too early. This work involved a couple changes: 1) Move the "frame" fence to be incremented on the rendering thread (during RHIAdvanceFrameForGetViewportBackBuffer()) so that resources that are deleted from the rendering thread are assosicated with the correct frame count 2) Queue up a command from the rendering thread to signal the "frame" fence. It needs to be queued to ensure that it's signaled at the correct time on the RHI thread (after that frame's command lists have been executed). -Disable GRHIRequiresEarlyBackBufferRenderTarget. Metal/Vulkan/Xbox11.x already do this. This is used by the Slate renderer during BeginRenderFrame and avoids a SetRenderTargets call. -Enable GRHISupportsMSAADepthSampleAccess (used in the Editor). This was enabled for D3D11 on SM5, but not for D3D12. -Delay load D3D12.dll and add root signature 1.1 support. -Add explicit flush calls to improve resource barrier batching instead of implict flushes inside FConditionalScopeResourceBarrier and FScopeResourceBarrier. Also update those classes with const members. *** CL 3183824 *** Fix the D3D12 RHI after integrating UE 4.14 updates: - Fixed a bug where we would try to get the PSO of a nullptr in SetPipelineState if we needed to reset the current PSO on the cmd list. - Fixed a spelling error - Removed the need for bForceState, we use dirty bits now *** CL 3183830 *** - GetDebugFlags RHI extension, needed by XB1 movie player. - Only query memory info if stats are enabled - Add support for the engine's new RHISubmitCommandsAndFlushGPU function - Update CommitPendingPipelineState to be Graphics/Compute specific and avoid the need for a IsCompute parameter. *** CL 3183837 *** Made PipelineState caches contain pointers to FD3D12PipelineState objects to avoid issues with using pointers to after Find/Add to the maps. TMap indicates that the pointer to the value associated with a key "is only valid until the next change to any key in the map." The lifetime of the PSO pointers is managed by the low level caches (graphics and compute). Added stat for the number of Pipeline State Objects. *** CL 3183931 *** Update Windows D3D12 headers and libs to RS1 release bits (10.0.14393.0) *** CL 3183978 *** Update UBT Windows build settings: - Change D3D12 PIX profiling enable/disable to match Xbox and handle logic in the UEBuildWindows.cs for UBT. Also add a static assert to inform the developer when PIX profiling is requested but the engine is compiling out draw events. -Delay load D3D12.dll and add root signature 1.1 support. *** CL 3184132 *** Fix Xbox PSO cache code where it could leak PSOs. Related to change 3183837. *** Changelist 3211714 *** Update D3D12 RHI with fixes: - Check if we can reserve slots in GatherUniqueSamplerTables - DirtyState more often in StateCache - Remove InternalSetSamplerState. The alternate function isn't used. - Allow MRTClear for arrays with holes in them - Fix uninitialized descriptors. This was causing a GPU hang on Xbox. We need to set dirty bits for resources bound to slots outside of the current descriptor table's range - Cleanup SetDescriptorHeap code. Move setting descriptor heap logic to the descriptor cache since it also owns things like the sampler maps. Added members to the descriptor cache to track the last heaps that were set on the command list to avoid dirtying bit unnecessarily. - Resource transitions: go through Common between queues (3D <--> Compute) - Fix initial state for placed resources. - Merging epic Change 3213250 on 2016/11/29 by Chris.Bunner GBufferHints tooltip fix. #jira UE-39103 Change 3213345 on 2016/11/29 by Gil.Gribb more IWYU fallout Change 3213676 on 2016/11/29 by Rolando.Caloca DR - Fix incorrect texture getting cleared Change 3213728 on 2016/11/29 by Rolando.Caloca DR - Lambda-ize Change 3214461 on 2016/11/29 by Ben.Woodhouse Rollout August QFE4 XDK (required for latest DX12 changes on XB1) Change 3215317 on 2016/11/30 by Daniel.Wright PS4 compile fix Change 3216343 on 2016/11/30 by Arne.Schober DR - UE-39155 - after talking to Brian it occurred to us that flipping the world space normal is non sensical. And indeed the Grass was using world space normals. Change 3216844 on 2016/12/01 by Ben.Woodhouse Fix for static analysis warnings after discussion with Microsoft Change 3216916 on 2016/12/01 by Gil.Gribb Merging //UE4/Dev-Main@3216539 to Dev-Rendering (//UE4/Dev-Rendering) Change 3217385 on 2016/12/01 by Arne.Schober DR - UE-39218, UE-39221, UE-39224 and potentially UE-39214 - The Stencil bits for Light channels and decal application were not set in the dynamic basepass Change 3217464 on 2016/12/01 by Ben.Woodhouse Fix for reflection capture resize assert. The assert is only valid in cooked builds, so disable it in editor #jira UE-39225 Change 3217534 on 2016/12/01 by Arne.Schober DR - Fix Merge conflict Change 3217581 on 2016/12/01 by Rolando.Caloca DR - Fix assert on debug Change 3217741 on 2016/12/01 by Benjamin.Hyder Duplicate audio fix. Change 3217890 on 2016/12/01 by Rolando.Caloca DR - Fix widget not rendering properly when hidden #jira UE-39221 Change3218129on 2016/12/01 by Arne.Schober DR - UE-39214 - Lod dither value as accidently cached accross the static draw list. Change 3218759 on 2016/12/02 by Guillaume.Abadie Fixes editor compositing bug caused by alpha through post processing change 3209903 #jira UE-39221 [CL 3219854 by Marcus Wassmer in Main branch]
2451 lines
104 KiB
C++
2451 lines
104 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
PostProcessing.cpp: The center for all post processing activities.
|
|
=============================================================================*/
|
|
|
|
#include "PostProcess/PostProcessing.h"
|
|
#include "EngineGlobals.h"
|
|
#include "ScenePrivate.h"
|
|
#include "PostProcess/PostProcessInput.h"
|
|
#include "PostProcess/PostProcessAA.h"
|
|
#if WITH_EDITOR
|
|
#include "PostProcess/PostProcessBufferInspector.h"
|
|
#endif
|
|
#include "PostProcess/PostProcessMaterial.h"
|
|
#include "PostProcess/PostProcessWeightedSampleSum.h"
|
|
#include "PostProcess/PostProcessBloomSetup.h"
|
|
#include "PostProcess/PostProcessMobile.h"
|
|
#include "PostProcess/PostProcessDownsample.h"
|
|
#include "PostProcess/PostProcessHistogram.h"
|
|
#include "PostProcess/PostProcessHistogramReduce.h"
|
|
#include "PostProcess/PostProcessVisualizeHDR.h"
|
|
#include "PostProcess/VisualizeShadingModels.h"
|
|
#include "PostProcess/PostProcessSelectionOutline.h"
|
|
#include "PostProcess/PostProcessGBufferHints.h"
|
|
#include "PostProcess/PostProcessVisualizeBuffer.h"
|
|
#include "PostProcess/PostProcessEyeAdaptation.h"
|
|
#include "PostProcess/PostProcessTonemap.h"
|
|
#include "PostProcess/PostProcessLensFlares.h"
|
|
#include "PostProcess/PostProcessLensBlur.h"
|
|
#include "PostProcess/PostProcessBokehDOF.h"
|
|
#include "PostProcess/PostProcessBokehDOFRecombine.h"
|
|
#include "PostProcess/PostProcessCombineLUTs.h"
|
|
#include "PostProcess/PostProcessTemporalAA.h"
|
|
#include "PostProcess/PostProcessMotionBlur.h"
|
|
#include "PostProcess/PostProcessDOF.h"
|
|
#include "PostProcess/PostProcessCircleDOF.h"
|
|
#include "PostProcess/PostProcessUpscale.h"
|
|
#include "PostProcess/PostProcessHMD.h"
|
|
#include "PostProcess/PostProcessVisualizeComplexity.h"
|
|
#include "PostProcess/PostProcessCompositeEditorPrimitives.h"
|
|
#include "CompositionLighting/PostProcessPassThrough.h"
|
|
#include "PostProcess/PostProcessTestImage.h"
|
|
#include "HighResScreenshot.h"
|
|
#include "PostProcess/PostProcessSubsurface.h"
|
|
#include "PostProcess/PostProcessMorpheus.h"
|
|
#include "IHeadMountedDisplay.h"
|
|
#include "BufferVisualizationData.h"
|
|
#include "CompositionLighting/PostProcessLpvIndirect.h"
|
|
#include "PostProcess/PostProcessStreamingAccuracyLegend.h"
|
|
#include "DeferredShadingRenderer.h"
|
|
|
|
/** The global center for all post processing activities. */
|
|
FPostProcessing GPostProcessing;
|
|
|
|
static TAutoConsoleVariable<int32> CVarUseMobileBloom(
|
|
TEXT("r.UseMobileBloom"),
|
|
0,
|
|
TEXT("HACK: Set to 1 to use mobile bloom."),
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<float> CVarDepthOfFieldNearBlurSizeThreshold(
|
|
TEXT("r.DepthOfField.NearBlurSizeThreshold"),
|
|
0.01f,
|
|
TEXT("Sets the minimum near blur size before the effect is forcably disabled. Currently only affects Gaussian DOF.\n")
|
|
TEXT(" (default: 0.01)"),
|
|
ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<float> CVarDepthOfFieldMaxSize(
|
|
TEXT("r.DepthOfField.MaxSize"),
|
|
100.0f,
|
|
TEXT("Allows to clamp the gaussian depth of field radius (for better performance), default: 100"),
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<int32> CVarRenderTargetSwitchWorkaround(
|
|
TEXT("r.RenderTargetSwitchWorkaround"),
|
|
0,
|
|
TEXT("Workaround needed on some mobile platforms to avoid a performance drop related to switching render targets.\n")
|
|
TEXT("Only enabled on some hardware. This affects the bloom quality a bit. It runs slower than the normal code path but\n")
|
|
TEXT("still faster as it avoids the many render target switches. (Default: 0)\n")
|
|
TEXT("We want this enabled (1) on all 32 bit iOS devices (implemented through DeviceProfiles)."),
|
|
ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<int32> CVarUpscaleQuality(
|
|
TEXT("r.Upscale.Quality"),
|
|
3,
|
|
TEXT("Defines the quality in which ScreenPercentage and WindowedFullscreen scales the 3d rendering.\n")
|
|
TEXT(" 0: Nearest filtering\n")
|
|
TEXT(" 1: Simple Bilinear\n")
|
|
TEXT(" 2: 4 tap bilinear\n")
|
|
TEXT(" 3: Directional blur with unsharp mask upsample. (default)"),
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<int32> CDownsampleQuality(
|
|
TEXT("r.Downsample.Quality"),
|
|
3,
|
|
TEXT("Defines the quality in which the Downsample passes. we might add more quality levels later.\n")
|
|
TEXT(" 0: low quality\n")
|
|
TEXT(">0: high quality (default: 3)\n"),
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<float> CVarMotionBlurSoftEdgeSize(
|
|
TEXT("r.MotionBlurSoftEdgeSize"),
|
|
1.0f,
|
|
TEXT("Defines how wide the object motion blur is blurred (percent of screen width) to allow soft edge motion blur.\n")
|
|
TEXT("This scales linearly with the size (up to a maximum of 32 samples, 2.5 is about 18 samples) and with screen resolution\n")
|
|
TEXT("Smaller values are better for performance and provide more accurate motion vectors but the blurring outside the object is reduced.\n")
|
|
TEXT("If needed this can be exposed like the other motionblur settings.\n")
|
|
TEXT(" 0:off (not free and does never completely disable), >0, 1.0 (default)"),
|
|
ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<float> CVarBloomCross(
|
|
TEXT("r.Bloom.Cross"),
|
|
0.0f,
|
|
TEXT("Experimental feature to give bloom kernel a more bright center sample (values between 1 and 3 work without causing aliasing)\n")
|
|
TEXT("Existing bloom get lowered to match the same brightness\n")
|
|
TEXT("<0 for a anisomorphic lens flare look (X only)\n")
|
|
TEXT(" 0 off (default)\n")
|
|
TEXT(">0 for a cross look (X and Y)"),
|
|
ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<int32> CVarTonemapperMergeMode(
|
|
TEXT("r.Tonemapper.MergeWithUpscale.Mode"),
|
|
0,
|
|
TEXT("ScreenPercentage upscale integrated into tonemapper pass (if certain conditions apply, e.g., no FXAA)\n")
|
|
TEXT(" if enabled both features are done in one pass (faster, affects post process passes after the tonemapper including material post process e.g. sharpen)\n")
|
|
TEXT(" 0: off, the features run in separate passes (default)\n")
|
|
TEXT(" 1: always enabled, try to merge the passes unless something makes it impossible\n")
|
|
TEXT(" 2: merge when the ratio of areas is above the r.Tonemapper.MergeWithUpscale.Threshold and it is otherwise possible"),
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<float> CVarTonemapperMergeThreshold(
|
|
TEXT("r.Tonemapper.MergeWithUpscale.Threshold"),
|
|
0.49f,
|
|
TEXT("If r.Tonemapper.MergeWithUpscale.Mode is 2, the ratio of the area before upscale/downscale to the area afterwards\n")
|
|
TEXT("is compared to this threshold when deciding whether or not to merge the passes. The reasoning is that if the ratio\n")
|
|
TEXT("is too low, running the tonemapper on the higher number of pixels is more expensive than doing two passes\n")
|
|
TEXT("\n")
|
|
TEXT("Defauls to 0.49 (e.g., if r.ScreenPercentage is 70 or higher, try to merge)"),
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
static TAutoConsoleVariable<int32> CVarMotionBlurScatter(
|
|
TEXT("r.MotionBlurScatter"),
|
|
0,
|
|
TEXT("Forces scatter based max velocity method (slower)."),
|
|
ECVF_RenderThreadSafe
|
|
);
|
|
|
|
static TAutoConsoleVariable<int32> CVarMotionBlurSeparable(
|
|
TEXT("r.MotionBlurSeparable"),
|
|
0,
|
|
TEXT("Adds a second motion blur pass that smooths noise for a higher quality blur."),
|
|
ECVF_RenderThreadSafe
|
|
);
|
|
|
|
IMPLEMENT_SHADER_TYPE(,FPostProcessVS,TEXT("PostProcessBloom"),TEXT("MainPostprocessCommonVS"),SF_Vertex);
|
|
|
|
static bool HasPostProcessMaterial(FPostprocessContext& Context, EBlendableLocation InLocation);
|
|
|
|
// -------------------------------------------------------
|
|
|
|
FPostprocessContext::FPostprocessContext(FRHICommandListImmediate& InRHICmdList, FRenderingCompositionGraph& InGraph, const FViewInfo& InView)
|
|
: RHICmdList(InRHICmdList)
|
|
, Graph(InGraph)
|
|
, View(InView)
|
|
, SceneColor(0)
|
|
, SceneDepth(0)
|
|
{
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(InRHICmdList);
|
|
if(SceneContext.IsSceneColorAllocated())
|
|
{
|
|
SceneColor = Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(SceneContext.GetSceneColor()));
|
|
}
|
|
|
|
SceneDepth = Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(SceneContext.SceneDepthZ));
|
|
|
|
FinalOutput = FRenderingCompositeOutputRef(SceneColor);
|
|
}
|
|
|
|
// Array of downsampled color with optional log2 luminance stored in alpha
|
|
template <int32 DownSampleStages>
|
|
class TBloomDownSampleArray
|
|
{
|
|
public:
|
|
// Convenience typedefs
|
|
typedef FRenderingCompositeOutputRef FRenderingRefArray[DownSampleStages];
|
|
typedef TSharedPtr<TBloomDownSampleArray> Ptr;
|
|
|
|
// Constructor: Generates and registers the downsamples with the Context Graph.
|
|
TBloomDownSampleArray(FPostprocessContext& InContext, FRenderingCompositeOutputRef SourceDownsample, bool bGenerateLog2Alpha) :
|
|
bHasLog2Alpha(bGenerateLog2Alpha), Context(InContext)
|
|
{
|
|
|
|
static const TCHAR* PassLabels[] =
|
|
{ NULL, TEXT("BloomDownsample1"), TEXT("BloomDownsample2"), TEXT("BloomDownsample3"), TEXT("BloomDownsample4"), TEXT("BloomDownsample5") };
|
|
static_assert(ARRAY_COUNT(PassLabels) == DownSampleStages, "PassLabel count must be equal to DownSampleStages.");
|
|
|
|
// The first down sample is the input
|
|
PostProcessDownsamples[0] = SourceDownsample;
|
|
|
|
// Queue the down samples.
|
|
for (int i = 1; i < DownSampleStages; i++)
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDownsample(PF_Unknown, 1, PassLabels[i]));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsamples[i - 1]);
|
|
PostProcessDownsamples[i] = FRenderingCompositeOutputRef(Pass);
|
|
|
|
// Add log2 data to the alpha channel after doing the 1st (i==1) down sample pass
|
|
if (bHasLog2Alpha && i == 1 ) {
|
|
FRenderingCompositePass* BasicEyeSetupPass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBasicEyeAdaptationSetUp());
|
|
BasicEyeSetupPass->SetInput(ePId_Input0, PostProcessDownsamples[i]);
|
|
PostProcessDownsamples[i] = FRenderingCompositeOutputRef(BasicEyeSetupPass);
|
|
}
|
|
}
|
|
}
|
|
|
|
// The number of elements in the array.
|
|
inline static int32 Num() { return DownSampleStages; }
|
|
|
|
// Member data kept public for simplicity
|
|
bool bHasLog2Alpha;
|
|
FPostprocessContext& Context;
|
|
FRenderingRefArray PostProcessDownsamples;
|
|
|
|
private:
|
|
// no default constructor.
|
|
TBloomDownSampleArray() {};
|
|
};
|
|
|
|
// Standard DownsampleArray shared by Bloom, Tint, and Eye-Adaptation.
|
|
typedef TBloomDownSampleArray<6/*DownSampleStages*/> FBloomDownSampleArray;
|
|
|
|
FBloomDownSampleArray::Ptr CreateDownSampleArray(FPostprocessContext& Context, FRenderingCompositeOutputRef SourceToDownSample, bool bAddLog2)
|
|
{
|
|
return FBloomDownSampleArray::Ptr(new FBloomDownSampleArray(Context, SourceToDownSample, bAddLog2));
|
|
}
|
|
|
|
|
|
static FRenderingCompositeOutputRef RenderHalfResBloomThreshold(FPostprocessContext& Context, FRenderingCompositeOutputRef SceneColorHalfRes, FRenderingCompositeOutputRef EyeAdaptation)
|
|
{
|
|
// with multiple view ports the Setup pass also isolates the view from the others which allows for simpler simpler/faster blur passes.
|
|
if(Context.View.FinalPostProcessSettings.BloomThreshold <= -1 && Context.View.Family->Views.Num() == 1)
|
|
{
|
|
// no need for threshold, we don't need this pass
|
|
return SceneColorHalfRes;
|
|
}
|
|
else
|
|
{
|
|
// todo: optimize later, the missing node causes some wrong behavior
|
|
// if(Context.View.FinalPostProcessSettings.BloomIntensity <= 0.0f)
|
|
// {
|
|
// // this pass is not required
|
|
// return FRenderingCompositeOutputRef();
|
|
// }
|
|
// bloom threshold
|
|
FRenderingCompositePass* PostProcessBloomSetup = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomSetup());
|
|
PostProcessBloomSetup->SetInput(ePId_Input0, SceneColorHalfRes);
|
|
PostProcessBloomSetup->SetInput(ePId_Input1, EyeAdaptation);
|
|
|
|
return FRenderingCompositeOutputRef(PostProcessBloomSetup);
|
|
}
|
|
}
|
|
|
|
|
|
// 2 pass Gaussian blur using uni-linear filtering
|
|
// @param CrossCenterWeight see r.Bloom.Cross (positive for X and Y, otherwise for X only)
|
|
static FRenderingCompositeOutputRef RenderGaussianBlur(
|
|
FPostprocessContext& Context,
|
|
const TCHAR* DebugNameX,
|
|
const TCHAR* DebugNameY,
|
|
const FRenderingCompositeOutputRef& Input,
|
|
float SizeScale,
|
|
FLinearColor Tint = FLinearColor::White,
|
|
const FRenderingCompositeOutputRef Additive = FRenderingCompositeOutputRef(),
|
|
float CrossCenterWeight = 0.0f)
|
|
{
|
|
// Gaussian blur in x
|
|
FRCPassPostProcessWeightedSampleSum* PostProcessBlurX = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessWeightedSampleSum(EFS_Horiz, EFCM_Weighted, SizeScale, DebugNameX));
|
|
PostProcessBlurX->SetInput(ePId_Input0, Input);
|
|
if(CrossCenterWeight > 0)
|
|
{
|
|
PostProcessBlurX->SetCrossCenterWeight(CrossCenterWeight);
|
|
}
|
|
|
|
// Gaussian blur in y
|
|
FRCPassPostProcessWeightedSampleSum* PostProcessBlurY = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessWeightedSampleSum(EFS_Vert, EFCM_Weighted, SizeScale, DebugNameY, Tint));
|
|
PostProcessBlurY->SetInput(ePId_Input0, FRenderingCompositeOutputRef(PostProcessBlurX));
|
|
PostProcessBlurY->SetInput(ePId_Input1, Additive);
|
|
PostProcessBlurY->SetCrossCenterWeight(FMath::Abs(CrossCenterWeight));
|
|
|
|
return FRenderingCompositeOutputRef(PostProcessBlurY);
|
|
}
|
|
|
|
// render one bloom pass and add another optional texture to it
|
|
static FRenderingCompositeOutputRef RenderBloom(
|
|
FPostprocessContext& Context,
|
|
const FRenderingCompositeOutputRef& PreviousBloom,
|
|
float Size,
|
|
FLinearColor Tint = FLinearColor::White,
|
|
const FRenderingCompositeOutputRef Additive = FRenderingCompositeOutputRef())
|
|
{
|
|
const float CrossBloom = CVarBloomCross.GetValueOnRenderThread();
|
|
|
|
return RenderGaussianBlur(Context, TEXT("BloomBlurX"), TEXT("BloomBlurY"), PreviousBloom, Size, Tint, Additive,CrossBloom);
|
|
}
|
|
|
|
static FRCPassPostProcessTonemap* AddTonemapper(
|
|
FPostprocessContext& Context,
|
|
const FRenderingCompositeOutputRef& BloomOutputCombined,
|
|
const FRenderingCompositeOutputRef& EyeAdaptation,
|
|
const EAutoExposureMethod& EyeAdapationMethodId,
|
|
const bool bDoGammaOnly,
|
|
const bool bHDRTonemapperOutput)
|
|
{
|
|
const FEngineShowFlags& EngineShowFlags = Context.View.Family->EngineShowFlags;
|
|
|
|
FRenderingCompositePass* CombinedLUT = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessCombineLUTs(Context.View.GetShaderPlatform()));
|
|
const bool bDoEyeAdaptation = IsAutoExposureMethodSupported(Context.View.GetFeatureLevel(), EyeAdapationMethodId);
|
|
FRCPassPostProcessTonemap* PostProcessTonemap = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessTonemap(Context.View, bDoGammaOnly, bDoEyeAdaptation, bHDRTonemapperOutput));
|
|
|
|
PostProcessTonemap->SetInput(ePId_Input0, Context.FinalOutput);
|
|
PostProcessTonemap->SetInput(ePId_Input1, BloomOutputCombined);
|
|
PostProcessTonemap->SetInput(ePId_Input2, EyeAdaptation);
|
|
PostProcessTonemap->SetInput(ePId_Input3, CombinedLUT);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(PostProcessTonemap);
|
|
|
|
return PostProcessTonemap;
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
static void AddSelectionOutline(FPostprocessContext& Context)
|
|
{
|
|
FRenderingCompositePass* SelectionColorPass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSelectionOutlineColor());
|
|
SelectionColorPass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSelectionOutline());
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Node->SetInput(ePId_Input1, FRenderingCompositeOutputRef(FRenderingCompositeOutputRef(SelectionColorPass)));
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
#endif
|
|
|
|
static void AddGammaOnlyTonemapper(FPostprocessContext& Context)
|
|
{
|
|
FRenderingCompositePass* PostProcessTonemap = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessTonemap(Context.View, true, false/*eye*/, false));
|
|
|
|
PostProcessTonemap->SetInput(ePId_Input0, Context.FinalOutput);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(PostProcessTonemap);
|
|
}
|
|
|
|
static void AddPostProcessAA(FPostprocessContext& Context)
|
|
{
|
|
// console variable override
|
|
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.PostProcessAAQuality"));
|
|
|
|
uint32 Quality = FMath::Clamp(CVar->GetValueOnRenderThread(), 1, 6);
|
|
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessAA(Quality));
|
|
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
|
|
static FRenderingCompositeOutputRef AddPostProcessBasicEyeAdaptation(const FViewInfo& View, FBloomDownSampleArray& BloomAndEyeDownSamples)
|
|
{
|
|
// Extract the context
|
|
FPostprocessContext& Context = BloomAndEyeDownSamples.Context;
|
|
|
|
// Extract the last (i.e. smallest) down sample
|
|
static const int32 FinalDSIdx = FBloomDownSampleArray::Num() - 1;
|
|
FRenderingCompositeOutputRef PostProcessPriorReduction = BloomAndEyeDownSamples.PostProcessDownsamples[FinalDSIdx];
|
|
|
|
// Compute the eye adaptation value based on average luminance from log2 luminance buffer, history, and specific shader parameters.
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBasicEyeAdaptation());
|
|
Node->SetInput(ePId_Input0, PostProcessPriorReduction);
|
|
return FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
static FRenderingCompositeOutputRef AddPostProcessHistogramEyeAdaptation(FPostprocessContext& Context, FRenderingCompositeOutputRef& Histogram)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessEyeAdaptation());
|
|
|
|
Node->SetInput(ePId_Input0, Histogram);
|
|
return FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
static void AddVisualizeBloomSetup(FPostprocessContext& Context)
|
|
{
|
|
auto Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeBloomSetup());
|
|
|
|
Node->SetInput(ePId_Input0, Context.FinalOutput);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
static void AddVisualizeBloomOverlay(FPostprocessContext& Context, FRenderingCompositeOutputRef& HDRColor, FRenderingCompositeOutputRef& BloomOutputCombined)
|
|
{
|
|
auto Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeBloomOverlay());
|
|
|
|
Node->SetInput(ePId_Input0, Context.FinalOutput);
|
|
Node->SetInput(ePId_Input1, HDRColor);
|
|
Node->SetInput(ePId_Input2, BloomOutputCombined);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
static void AddPostProcessDepthOfFieldBokeh(FPostprocessContext& Context, FRenderingCompositeOutputRef& SeparateTranslucency, FRenderingCompositeOutputRef& VelocityInput)
|
|
{
|
|
// downsample, mask out the in focus part, depth in alpha
|
|
FRenderingCompositePass* DOFSetup = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBokehDOFSetup());
|
|
DOFSetup->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
DOFSetup->SetInput(ePId_Input1, FRenderingCompositeOutputRef(Context.SceneDepth));
|
|
|
|
FSceneViewState* ViewState = (FSceneViewState*)Context.View.State;
|
|
|
|
FRenderingCompositePass* DOFInputPass = DOFSetup;
|
|
if( Context.View.AntiAliasingMethod == AAM_TemporalAA && ViewState )
|
|
{
|
|
FRenderingCompositePass* HistoryInput;
|
|
if( ViewState->DOFHistoryRT && ViewState->bDOFHistory && !Context.View.bCameraCut )
|
|
{
|
|
HistoryInput = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessInput( ViewState->DOFHistoryRT ) );
|
|
}
|
|
else
|
|
{
|
|
// No history so use current as history
|
|
HistoryInput = DOFSetup;
|
|
}
|
|
|
|
FRenderingCompositePass* NodeTemporalAA = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessDOFTemporalAA );
|
|
NodeTemporalAA->SetInput( ePId_Input0, DOFSetup );
|
|
NodeTemporalAA->SetInput( ePId_Input1, FRenderingCompositeOutputRef( HistoryInput ) );
|
|
NodeTemporalAA->SetInput( ePId_Input2, FRenderingCompositeOutputRef( HistoryInput ) );
|
|
NodeTemporalAA->SetInput( ePId_Input3, VelocityInput );
|
|
|
|
DOFInputPass = NodeTemporalAA;
|
|
ViewState->bDOFHistory = true;
|
|
}
|
|
|
|
FRenderingCompositePass* NodeBlurred = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBokehDOF());
|
|
NodeBlurred->SetInput(ePId_Input0, DOFInputPass);
|
|
NodeBlurred->SetInput(ePId_Input1, Context.SceneColor);
|
|
NodeBlurred->SetInput(ePId_Input2, Context.SceneDepth);
|
|
|
|
FRenderingCompositePass* NodeRecombined = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBokehDOFRecombine());
|
|
NodeRecombined->SetInput(ePId_Input0, Context.FinalOutput);
|
|
NodeRecombined->SetInput(ePId_Input1, NodeBlurred);
|
|
NodeRecombined->SetInput(ePId_Input2, SeparateTranslucency);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(NodeRecombined);
|
|
}
|
|
|
|
static bool AddPostProcessDepthOfFieldGaussian(FPostprocessContext& Context, FDepthOfFieldStats& Out, FRenderingCompositeOutputRef& VelocityInput, FRenderingCompositeOutputRef& SeparateTranslucencyRef)
|
|
{
|
|
// GaussianDOFPass performs Gaussian setup, blur and recombine.
|
|
auto GaussianDOFPass = [&Context, &Out, &VelocityInput](FRenderingCompositeOutputRef& SeparateTranslucency, float FarSize, float NearSize)
|
|
{
|
|
// GenerateGaussianDOFBlur produces a blurred image from setup or potentially from taa result.
|
|
auto GenerateGaussianDOFBlur = [&Context, &VelocityInput](FRenderingCompositeOutputRef& DOFSetup, bool bFarPass, float BlurSize)
|
|
{
|
|
FSceneViewState* ViewState = (FSceneViewState*)Context.View.State;
|
|
|
|
FRenderingCompositeOutputRef DOFInputPass = DOFSetup;
|
|
const bool bMobileQuality = (Context.View.GetFeatureLevel() <= ERHIFeatureLevel::ES3_1);
|
|
if (Context.View.AntiAliasingMethod == AAM_TemporalAA && ViewState && !bMobileQuality)
|
|
{
|
|
// If no history use current as history
|
|
FRenderingCompositeOutputRef HistoryInput = DOFSetup;
|
|
|
|
TRefCountPtr<IPooledRenderTarget> DOFHistoryRT = bFarPass ? ViewState->DOFHistoryRT : ViewState->DOFHistoryRT2;
|
|
bool& bDOFHistory = bFarPass ? ViewState->bDOFHistory : ViewState->bDOFHistory2;
|
|
|
|
if (DOFHistoryRT && !bDOFHistory && !Context.View.bCameraCut)
|
|
{
|
|
HistoryInput = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(DOFHistoryRT));
|
|
}
|
|
|
|
FRenderingCompositePass* NodeTemporalAA = bFarPass ?
|
|
(FRenderingCompositePass*)Context.Graph.RegisterPass(new (FMemStack::Get()) FRCPassPostProcessDOFTemporalAA) :
|
|
(FRenderingCompositePass*)Context.Graph.RegisterPass(new (FMemStack::Get()) FRCPassPostProcessDOFTemporalAANear);
|
|
|
|
NodeTemporalAA->SetInput(ePId_Input0, DOFSetup);
|
|
NodeTemporalAA->SetInput(ePId_Input1, HistoryInput);
|
|
NodeTemporalAA->SetInput(ePId_Input2, HistoryInput);
|
|
NodeTemporalAA->SetInput(ePId_Input3, VelocityInput);
|
|
|
|
DOFInputPass = FRenderingCompositeOutputRef(NodeTemporalAA);
|
|
bDOFHistory = false;
|
|
}
|
|
|
|
const TCHAR* BlurDebugX = bFarPass ? TEXT("FarDOFBlurX") : TEXT("NearDOFBlurX");
|
|
const TCHAR* BlurDebugY = bFarPass ? TEXT("FarDOFBlurY") : TEXT("NearDOFBlurY");
|
|
|
|
return RenderGaussianBlur(Context, BlurDebugX, BlurDebugY, DOFInputPass, BlurSize);
|
|
};
|
|
|
|
const bool bFar = FarSize > 0.0f;
|
|
const bool bNear = NearSize > 0.0f;
|
|
const bool bCombinedNearFarPass = bFar && bNear;
|
|
const bool bMobileQuality = Context.View.FeatureLevel < ERHIFeatureLevel::SM4;
|
|
|
|
FRenderingCompositeOutputRef SetupInput(Context.FinalOutput);
|
|
if (bMobileQuality)
|
|
{
|
|
FRenderingCompositePass* HalfResFar = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDownsample(PF_FloatRGBA, 1, TEXT("GausSetupHalfRes")));
|
|
HalfResFar->SetInput(ePId_Input0, FRenderingCompositeOutputRef(SetupInput));
|
|
SetupInput = HalfResFar;
|
|
}
|
|
|
|
FRenderingCompositePass* DOFSetupPass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDOFSetup(bFar, bNear));
|
|
DOFSetupPass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(SetupInput));
|
|
DOFSetupPass->SetInput(ePId_Input1, FRenderingCompositeOutputRef(Context.SceneDepth));
|
|
FRenderingCompositeOutputRef DOFSetupFar(DOFSetupPass);
|
|
FRenderingCompositeOutputRef DOFSetupNear(DOFSetupPass, bCombinedNearFarPass ? ePId_Output1 : ePId_Output0);
|
|
|
|
FRenderingCompositeOutputRef DOFFarBlur, DOFNearBlur;
|
|
if (bFar)
|
|
{
|
|
DOFFarBlur = GenerateGaussianDOFBlur(DOFSetupFar, true, FarSize);
|
|
}
|
|
|
|
if (bNear)
|
|
{
|
|
DOFNearBlur = GenerateGaussianDOFBlur(DOFSetupNear, false, NearSize);
|
|
}
|
|
|
|
FRenderingCompositePass* GaussianDOFRecombined = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDOFRecombine());
|
|
GaussianDOFRecombined->SetInput(ePId_Input0, Context.FinalOutput);
|
|
GaussianDOFRecombined->SetInput(ePId_Input1, DOFFarBlur);
|
|
GaussianDOFRecombined->SetInput(ePId_Input2, DOFNearBlur);
|
|
GaussianDOFRecombined->SetInput(ePId_Input3, SeparateTranslucency);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(GaussianDOFRecombined);
|
|
};
|
|
|
|
float FarSize = Context.View.FinalPostProcessSettings.DepthOfFieldFarBlurSize;
|
|
float NearSize = Context.View.FinalPostProcessSettings.DepthOfFieldNearBlurSize;
|
|
const float MaxSize = CVarDepthOfFieldMaxSize.GetValueOnRenderThread();
|
|
FarSize = FMath::Min(FarSize, MaxSize);
|
|
NearSize = FMath::Min(NearSize, MaxSize);
|
|
Out.bFar = FarSize >= 0.01f;
|
|
|
|
{
|
|
const float CVarThreshold = CVarDepthOfFieldNearBlurSizeThreshold.GetValueOnRenderThread();
|
|
Out.bNear = (NearSize >= CVarThreshold);
|
|
}
|
|
|
|
if (Context.View.Family->EngineShowFlags.VisualizeDOF)
|
|
{
|
|
// no need for this pass
|
|
Out.bFar = false;
|
|
Out.bNear = false;
|
|
}
|
|
|
|
const bool bMobileQuality = Context.View.FeatureLevel < ERHIFeatureLevel::SM4;
|
|
const bool bShouldApplySepTrans = SeparateTranslucencyRef.IsValid() && !bMobileQuality;
|
|
const bool bCombineNearFarPass = !bShouldApplySepTrans && Out.bFar && Out.bNear;
|
|
|
|
if (bCombineNearFarPass)
|
|
{
|
|
GaussianDOFPass(SeparateTranslucencyRef, FarSize, NearSize);
|
|
}
|
|
else
|
|
{
|
|
FRenderingCompositeOutputRef SeparateTranslucency = SeparateTranslucencyRef;
|
|
if (Out.bFar)
|
|
{
|
|
GaussianDOFPass(SeparateTranslucency, FarSize, 0.0f);
|
|
SeparateTranslucency = FRenderingCompositeOutputRef();
|
|
}
|
|
if (Out.bNear)
|
|
{
|
|
GaussianDOFPass(SeparateTranslucency, 0.0f, NearSize);
|
|
}
|
|
}
|
|
|
|
return bShouldApplySepTrans && (Out.bFar || Out.bNear);
|
|
}
|
|
|
|
static void AddPostProcessDepthOfFieldCircle(FPostprocessContext& Context, FDepthOfFieldStats& Out, FRenderingCompositeOutputRef& VelocityInput)
|
|
{
|
|
if(Context.View.Family->EngineShowFlags.VisualizeDOF)
|
|
{
|
|
// no need for this pass
|
|
return;
|
|
}
|
|
|
|
FRenderingCompositePass* DOFSetup = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessCircleDOFSetup());
|
|
DOFSetup->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
DOFSetup->SetInput(ePId_Input1, FRenderingCompositeOutputRef(Context.SceneDepth));
|
|
|
|
FSceneViewState* ViewState = (FSceneViewState*)Context.View.State;
|
|
|
|
FRenderingCompositePass* DOFInputPass = DOFSetup;
|
|
auto CocSetup = FRenderingCompositeOutputRef( DOFSetup, SupportSceneAlpha() ? ePId_Output1 : ePId_Output0 );
|
|
if( Context.View.AntiAliasingMethod == AAM_TemporalAA && ViewState )
|
|
{
|
|
FRenderingCompositePass* HistoryInput;
|
|
if( ViewState->DOFHistoryRT && !ViewState->bDOFHistory && !Context.View.bCameraCut )
|
|
{
|
|
HistoryInput = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessInput( ViewState->DOFHistoryRT ) );
|
|
}
|
|
else
|
|
{
|
|
// No history so use current as history
|
|
HistoryInput = DOFSetup;
|
|
}
|
|
|
|
FRenderingCompositePass* NodeTemporalAA = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessDOFTemporalAA );
|
|
NodeTemporalAA->SetInput( ePId_Input0, CocSetup );
|
|
NodeTemporalAA->SetInput( ePId_Input1, FRenderingCompositeOutputRef( HistoryInput ) );
|
|
NodeTemporalAA->SetInput( ePId_Input2, FRenderingCompositeOutputRef( HistoryInput ) );
|
|
NodeTemporalAA->SetInput( ePId_Input3, VelocityInput );
|
|
|
|
CocSetup = FRenderingCompositeOutputRef( NodeTemporalAA );
|
|
ViewState->bDOFHistory = false;
|
|
}
|
|
|
|
FRenderingCompositePass* DOFNear = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessCircleDOFDilate());
|
|
DOFNear->SetInput(ePId_Input0, CocSetup);
|
|
FRenderingCompositeOutputRef Near = FRenderingCompositeOutputRef(DOFNear, ePId_Output0);
|
|
|
|
FRenderingCompositePass* DOFApply = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessCircleDOF());
|
|
DOFApply->SetInput(ePId_Input0, FRenderingCompositeOutputRef(DOFInputPass, ePId_Output0));
|
|
DOFApply->SetInput(ePId_Input1, Near);
|
|
DOFApply->SetInput(ePId_Input2, CocSetup);
|
|
FRenderingCompositeOutputRef Far = FRenderingCompositeOutputRef(DOFApply, ePId_Output0);
|
|
FRenderingCompositeOutputRef FarCoc = SupportSceneAlpha() ? FRenderingCompositeOutputRef(DOFApply, ePId_Output1) : Far;
|
|
|
|
FRenderingCompositePass* NodeRecombined = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessCircleDOFRecombine());
|
|
NodeRecombined->SetInput(ePId_Input0, Context.FinalOutput);
|
|
NodeRecombined->SetInput(ePId_Input1, Far);
|
|
NodeRecombined->SetInput(ePId_Input2, FarCoc);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(NodeRecombined);
|
|
}
|
|
|
|
|
|
static FRenderingCompositeOutputRef AddBloom(FBloomDownSampleArray& BloomDownSampleArray, bool bVisualizeBloom)
|
|
{
|
|
|
|
// Quality level to bloom stages table. Note: 0 is omitted, ensure element count tallys with the range documented with 'r.BloomQuality' definition.
|
|
const static uint32 BloomQualityStages[] =
|
|
{
|
|
3,// Q1
|
|
3,// Q2
|
|
4,// Q3
|
|
5,// Q4
|
|
6,// Q5
|
|
};
|
|
|
|
int32 BloomQuality;
|
|
{
|
|
// console variable override
|
|
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.BloomQuality"));
|
|
BloomQuality = FMath::Clamp(CVar->GetValueOnRenderThread(), 0, (int32)ARRAY_COUNT(BloomQualityStages));
|
|
}
|
|
|
|
// Extract the Context
|
|
FPostprocessContext& Context = BloomDownSampleArray.Context;
|
|
|
|
// Extract the downsample array.
|
|
FBloomDownSampleArray::FRenderingRefArray& PostProcessDownsamples = BloomDownSampleArray.PostProcessDownsamples;
|
|
|
|
FRenderingCompositeOutputRef BloomOutput;
|
|
if (BloomQuality == 0)
|
|
{
|
|
// No bloom, provide substitute source for lens flare.
|
|
BloomOutput = PostProcessDownsamples[0];
|
|
}
|
|
else
|
|
{
|
|
// Perform bloom blur + accumulate.
|
|
struct FBloomStage
|
|
{
|
|
float BloomSize;
|
|
const FLinearColor* Tint;
|
|
};
|
|
const FFinalPostProcessSettings& Settings = Context.View.FinalPostProcessSettings;
|
|
|
|
FBloomStage BloomStages[] =
|
|
{
|
|
{ Settings.Bloom6Size, &Settings.Bloom6Tint },
|
|
{ Settings.Bloom5Size, &Settings.Bloom5Tint },
|
|
{ Settings.Bloom4Size, &Settings.Bloom4Tint },
|
|
{ Settings.Bloom3Size, &Settings.Bloom3Tint },
|
|
{ Settings.Bloom2Size, &Settings.Bloom2Tint },
|
|
{ Settings.Bloom1Size, &Settings.Bloom1Tint },
|
|
};
|
|
static const uint32 NumBloomStages = ARRAY_COUNT(BloomStages);
|
|
|
|
const uint32 BloomStageCount = BloomQualityStages[BloomQuality - 1];
|
|
check(BloomStageCount <= NumBloomStages);
|
|
float TintScale = 1.0f / NumBloomStages;
|
|
for (uint32 i = 0, SourceIndex = NumBloomStages - 1; i < BloomStageCount; i++, SourceIndex--)
|
|
{
|
|
FBloomStage& Op = BloomStages[i];
|
|
|
|
FLinearColor Tint = (*Op.Tint) * TintScale;
|
|
|
|
if (bVisualizeBloom)
|
|
{
|
|
float LumScale = Tint.ComputeLuminance();
|
|
|
|
// R is used to pass down the reference, G is the emulated bloom
|
|
Tint.R = 0;
|
|
Tint.G = LumScale;
|
|
Tint.B = 0;
|
|
}
|
|
|
|
BloomOutput = RenderBloom(Context, PostProcessDownsamples[SourceIndex], Op.BloomSize * Settings.BloomSizeScale, Tint, BloomOutput);
|
|
}
|
|
}
|
|
|
|
// Lens Flares
|
|
FLinearColor LensFlareHDRColor = Context.View.FinalPostProcessSettings.LensFlareTint * Context.View.FinalPostProcessSettings.LensFlareIntensity;
|
|
static const int32 MaxLensFlareQuality = 3;
|
|
int32 LensFlareQuality;
|
|
{
|
|
// console variable override
|
|
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.LensFlareQuality"));
|
|
LensFlareQuality = FMath::Clamp(CVar->GetValueOnRenderThread(), 0, MaxLensFlareQuality);
|
|
}
|
|
|
|
if (!LensFlareHDRColor.IsAlmostBlack() && LensFlareQuality > 0 && !bVisualizeBloom)
|
|
{
|
|
float PercentKernelSize = Context.View.FinalPostProcessSettings.LensFlareBokehSize;
|
|
|
|
bool bLensBlur = PercentKernelSize > 0.3f;
|
|
|
|
FRenderingCompositePass* PostProcessFlares = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessLensFlares(bLensBlur ? 2.0f : 1.0f));
|
|
|
|
PostProcessFlares->SetInput(ePId_Input0, BloomOutput);
|
|
|
|
FRenderingCompositeOutputRef LensFlareInput = PostProcessDownsamples[MaxLensFlareQuality - LensFlareQuality];
|
|
|
|
if (bLensBlur)
|
|
{
|
|
float Threshold = Context.View.FinalPostProcessSettings.LensFlareThreshold;
|
|
|
|
FRenderingCompositePass* PostProcessLensBlur = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessLensBlur(PercentKernelSize, Threshold));
|
|
PostProcessLensBlur->SetInput(ePId_Input0, LensFlareInput);
|
|
PostProcessFlares->SetInput(ePId_Input1, FRenderingCompositeOutputRef(PostProcessLensBlur));
|
|
}
|
|
else
|
|
{
|
|
// fast: no blurring or blurring shared from bloom
|
|
PostProcessFlares->SetInput(ePId_Input1, LensFlareInput);
|
|
}
|
|
|
|
BloomOutput = FRenderingCompositeOutputRef(PostProcessFlares);
|
|
}
|
|
|
|
return BloomOutput;
|
|
}
|
|
|
|
static void AddTemporalAA( FPostprocessContext& Context, FRenderingCompositeOutputRef& VelocityInput )
|
|
{
|
|
check(VelocityInput.IsValid());
|
|
|
|
FSceneViewState* ViewState = (FSceneViewState*)Context.View.State;
|
|
|
|
FRenderingCompositePass* HistoryInput;
|
|
if( ViewState && ViewState->TemporalAAHistoryRT && !Context.View.bCameraCut )
|
|
{
|
|
HistoryInput = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessInput( ViewState->TemporalAAHistoryRT ) );
|
|
}
|
|
else
|
|
{
|
|
// No history so use current as history
|
|
HistoryInput = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessInput( FSceneRenderTargets::Get(Context.RHICmdList).GetSceneColor() ) );
|
|
}
|
|
|
|
FRenderingCompositePass* TemporalAAPass = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessTemporalAA );
|
|
TemporalAAPass->SetInput( ePId_Input0, Context.FinalOutput );
|
|
TemporalAAPass->SetInput( ePId_Input1, FRenderingCompositeOutputRef( HistoryInput ) );
|
|
TemporalAAPass->SetInput( ePId_Input2, FRenderingCompositeOutputRef( HistoryInput ) );
|
|
TemporalAAPass->SetInput( ePId_Input3, VelocityInput );
|
|
Context.FinalOutput = FRenderingCompositeOutputRef( TemporalAAPass );
|
|
}
|
|
|
|
FPostProcessMaterialNode* IteratePostProcessMaterialNodes(const FFinalPostProcessSettings& Dest, EBlendableLocation InLocation, FBlendableEntry*& Iterator)
|
|
{
|
|
for(;;)
|
|
{
|
|
FPostProcessMaterialNode* DataPtr = Dest.BlendableManager.IterateBlendables<FPostProcessMaterialNode>(Iterator);
|
|
|
|
if(!DataPtr || DataPtr->GetLocation() == InLocation)
|
|
{
|
|
return DataPtr;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
static FRenderingCompositePass* AddSinglePostProcessMaterial(FPostprocessContext& Context, EBlendableLocation InLocation)
|
|
{
|
|
if(!Context.View.Family->EngineShowFlags.PostProcessing || !Context.View.Family->EngineShowFlags.PostProcessMaterial)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
FBlendableEntry* Iterator = 0;
|
|
FPostProcessMaterialNode PPNode;
|
|
|
|
while(FPostProcessMaterialNode* Data = IteratePostProcessMaterialNodes(Context.View.FinalPostProcessSettings, InLocation, Iterator))
|
|
{
|
|
check(Data->GetMaterialInterface());
|
|
|
|
if(PPNode.IsValid())
|
|
{
|
|
FPostProcessMaterialNode::FCompare Dummy;
|
|
|
|
// take the one with the highest priority
|
|
if(!Dummy.operator()(PPNode, *Data))
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
PPNode = *Data;
|
|
}
|
|
|
|
if(UMaterialInterface* MaterialInterface = PPNode.GetMaterialInterface())
|
|
{
|
|
FMaterialRenderProxy* Proxy = MaterialInterface->GetRenderProxy(false);
|
|
|
|
check(Proxy);
|
|
|
|
const FMaterial* Material = Proxy->GetMaterial(Context.View.GetFeatureLevel());
|
|
|
|
check(Material);
|
|
|
|
if(Material->NeedsGBuffer())
|
|
{
|
|
// AdjustGBufferRefCount(-1) call is done when the pass gets executed
|
|
FSceneRenderTargets::Get(Context.RHICmdList).AdjustGBufferRefCount(Context.RHICmdList, 1);
|
|
}
|
|
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessMaterial(MaterialInterface, Context.View.GetFeatureLevel()));
|
|
|
|
return Node;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
// simplied version of AddPostProcessMaterial(), side effect free
|
|
static bool HasPostProcessMaterial(FPostprocessContext& Context, EBlendableLocation InLocation)
|
|
{
|
|
if(!Context.View.Family->EngineShowFlags.PostProcessing || !Context.View.Family->EngineShowFlags.PostProcessMaterial)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if(Context.View.Family->EngineShowFlags.VisualizeBuffer)
|
|
{
|
|
// Apply requested material to the full screen
|
|
UMaterial* Material = GetBufferVisualizationData().GetMaterial(Context.View.CurrentBufferVisualizationMode);
|
|
|
|
if(Material && Material->BlendableLocation == InLocation)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
FBlendableEntry* Iterator = 0;
|
|
FPostProcessMaterialNode* Data = IteratePostProcessMaterialNodes(Context.View.FinalPostProcessSettings, InLocation, Iterator);
|
|
|
|
if(Data)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static void AddPostProcessMaterial(FPostprocessContext& Context, EBlendableLocation InLocation, FRenderingCompositeOutputRef SeparateTranslucency, FRenderingCompositeOutputRef PreTonemapHDRColor = FRenderingCompositeOutputRef(), FRenderingCompositeOutputRef PostTonemapHDRColor = FRenderingCompositeOutputRef())
|
|
{
|
|
if( !Context.View.Family->EngineShowFlags.PostProcessing ||
|
|
!Context.View.Family->EngineShowFlags.PostProcessMaterial ||
|
|
Context.View.Family->EngineShowFlags.VisualizeShadingModels) // we should add more
|
|
{
|
|
return;
|
|
}
|
|
|
|
// hard coded - this should be a reasonable limit
|
|
const uint32 MAX_PPMATERIALNODES = 10;
|
|
FBlendableEntry* Iterator = 0;
|
|
FPostProcessMaterialNode PPNodes[MAX_PPMATERIALNODES];
|
|
uint32 PPNodeCount = 0;
|
|
bool bVisualizingBuffer = false;
|
|
|
|
if(Context.View.Family->EngineShowFlags.VisualizeBuffer)
|
|
{
|
|
// Apply requested material to the full screen
|
|
UMaterial* Material = GetBufferVisualizationData().GetMaterial(Context.View.CurrentBufferVisualizationMode);
|
|
|
|
if(Material && Material->BlendableLocation == InLocation)
|
|
{
|
|
PPNodes[0] = FPostProcessMaterialNode(Material, InLocation, Material->BlendablePriority);
|
|
++PPNodeCount;
|
|
bVisualizingBuffer = true;
|
|
}
|
|
}
|
|
for(;PPNodeCount < MAX_PPMATERIALNODES; ++PPNodeCount)
|
|
{
|
|
FPostProcessMaterialNode* Data = IteratePostProcessMaterialNodes(Context.View.FinalPostProcessSettings, InLocation, Iterator);
|
|
|
|
if(!Data)
|
|
{
|
|
break;
|
|
}
|
|
|
|
check(Data->GetMaterialInterface());
|
|
|
|
PPNodes[PPNodeCount] = *Data;
|
|
}
|
|
|
|
::Sort(PPNodes, PPNodeCount, FPostProcessMaterialNode::FCompare());
|
|
|
|
ERHIFeatureLevel::Type FeatureLevel = Context.View.GetFeatureLevel();
|
|
|
|
for(uint32 i = 0; i < PPNodeCount; ++i)
|
|
{
|
|
UMaterialInterface* MaterialInterface = PPNodes[i].GetMaterialInterface();
|
|
|
|
FMaterialRenderProxy* Proxy = MaterialInterface->GetRenderProxy(false);
|
|
|
|
check(Proxy);
|
|
|
|
const FMaterial* Material = Proxy->GetMaterial(Context.View.GetFeatureLevel());
|
|
|
|
check(Material);
|
|
|
|
if(Material->NeedsGBuffer())
|
|
{
|
|
// AdjustGBufferRefCount(-1) call is done when the pass gets executed
|
|
FSceneRenderTargets::Get(Context.RHICmdList).AdjustGBufferRefCount(Context.RHICmdList, 1);
|
|
}
|
|
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessMaterial(MaterialInterface,FeatureLevel));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
|
|
// We are binding separate translucency here because the post process SceneTexture node can reference
|
|
// the separate translucency buffers through ePId_Input1.
|
|
// TODO: Check if material actually uses this texture and only bind if needed.
|
|
Node->SetInput(ePId_Input1, SeparateTranslucency);
|
|
|
|
// This input is only needed for visualization and frame dumping
|
|
if (bVisualizingBuffer)
|
|
{
|
|
Node->SetInput(ePId_Input2, PreTonemapHDRColor);
|
|
Node->SetInput(ePId_Input3, PostTonemapHDRColor);
|
|
}
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
}
|
|
|
|
static void AddHighResScreenshotMask(FPostprocessContext& Context, FRenderingCompositeOutputRef& SeparateTranslucencyInput)
|
|
{
|
|
if (Context.View.Family->EngineShowFlags.HighResScreenshotMask != 0)
|
|
{
|
|
check(Context.View.FinalPostProcessSettings.HighResScreenshotMaterial);
|
|
|
|
FRenderingCompositeOutputRef Input = Context.FinalOutput;
|
|
|
|
FRenderingCompositePass* CompositePass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessMaterial(Context.View.FinalPostProcessSettings.HighResScreenshotMaterial, Context.View.GetFeatureLevel()));
|
|
CompositePass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Input));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(CompositePass);
|
|
|
|
if (GIsHighResScreenshot)
|
|
{
|
|
check(Context.View.FinalPostProcessSettings.HighResScreenshotMaskMaterial);
|
|
|
|
FRenderingCompositePass* MaskPass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessMaterial(Context.View.FinalPostProcessSettings.HighResScreenshotMaskMaterial, Context.View.GetFeatureLevel()));
|
|
MaskPass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Input));
|
|
CompositePass->AddDependency(MaskPass);
|
|
|
|
FString BaseFilename = FString(Context.View.FinalPostProcessSettings.BufferVisualizationDumpBaseFilename);
|
|
MaskPass->SetOutputColorArray(ePId_Output0, FScreenshotRequest::GetHighresScreenshotMaskColorArray());
|
|
}
|
|
}
|
|
|
|
// Draw the capture region if a material was supplied
|
|
if (Context.View.FinalPostProcessSettings.HighResScreenshotCaptureRegionMaterial)
|
|
{
|
|
auto Material = Context.View.FinalPostProcessSettings.HighResScreenshotCaptureRegionMaterial;
|
|
|
|
FRenderingCompositePass* CaptureRegionVisualizationPass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessMaterial(Material, Context.View.GetFeatureLevel()));
|
|
CaptureRegionVisualizationPass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(CaptureRegionVisualizationPass);
|
|
|
|
auto Proxy = Material->GetRenderProxy(false);
|
|
const FMaterial* RendererMaterial = Proxy->GetMaterial(Context.View.GetFeatureLevel());
|
|
if (RendererMaterial->NeedsGBuffer())
|
|
{
|
|
// AdjustGBufferRefCount(-1) call is done when the pass gets executed
|
|
FSceneRenderTargets::Get(Context.RHICmdList).AdjustGBufferRefCount(Context.RHICmdList, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void AddGBufferVisualizationOverview(FPostprocessContext& Context, FRenderingCompositeOutputRef& SeparateTranslucencyInput, FRenderingCompositeOutputRef& PreTonemapHDRColorInput, FRenderingCompositeOutputRef& PostTonemapHDRColorInput)
|
|
{
|
|
static const auto CVarDumpFrames = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.BufferVisualizationDumpFrames"));
|
|
static const auto CVarDumpFramesAsHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.BufferVisualizationDumpFramesAsHDR"));
|
|
|
|
bool bVisualizationEnabled = Context.View.Family->EngineShowFlags.VisualizeBuffer;
|
|
bool bOverviewModeEnabled = bVisualizationEnabled && (Context.View.CurrentBufferVisualizationMode == NAME_None);
|
|
bool bHighResBufferVisualizationDumpRequried = GIsHighResScreenshot && GetHighResScreenshotConfig().bDumpBufferVisualizationTargets;
|
|
bool bDumpFrames = Context.View.FinalPostProcessSettings.bBufferVisualizationDumpRequired && (CVarDumpFrames->GetValueOnRenderThread() || bHighResBufferVisualizationDumpRequried);
|
|
bool bCaptureAsHDR = CVarDumpFramesAsHDR->GetValueOnRenderThread() || GetHighResScreenshotConfig().bCaptureHDR;
|
|
FString BaseFilename;
|
|
|
|
if (bDumpFrames)
|
|
{
|
|
BaseFilename = FString(Context.View.FinalPostProcessSettings.BufferVisualizationDumpBaseFilename);
|
|
}
|
|
|
|
if (bDumpFrames || bVisualizationEnabled)
|
|
{
|
|
FRenderingCompositeOutputRef IncomingStage = Context.FinalOutput;
|
|
|
|
if (bDumpFrames || bOverviewModeEnabled)
|
|
{
|
|
FRenderingCompositePass* CompositePass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeBuffer());
|
|
CompositePass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(IncomingStage));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(CompositePass);
|
|
EPixelFormat OutputFormat = bCaptureAsHDR ? PF_FloatRGBA : PF_Unknown;
|
|
|
|
// Loop over materials, creating stages for generation and downsampling of the tiles.
|
|
for (TArray<UMaterialInterface*>::TConstIterator It = Context.View.FinalPostProcessSettings.BufferVisualizationOverviewMaterials.CreateConstIterator(); It; ++It)
|
|
{
|
|
auto MaterialInterface = *It;
|
|
if (MaterialInterface)
|
|
{
|
|
// Apply requested material
|
|
FRenderingCompositePass* MaterialPass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessMaterial(*It, Context.View.GetFeatureLevel(), OutputFormat));
|
|
MaterialPass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(IncomingStage));
|
|
MaterialPass->SetInput(ePId_Input1, FRenderingCompositeOutputRef(SeparateTranslucencyInput));
|
|
MaterialPass->SetInput(ePId_Input2, FRenderingCompositeOutputRef(PreTonemapHDRColorInput));
|
|
MaterialPass->SetInput(ePId_Input3, FRenderingCompositeOutputRef(PostTonemapHDRColorInput));
|
|
|
|
auto Proxy = MaterialInterface->GetRenderProxy(false);
|
|
const FMaterial* Material = Proxy->GetMaterial(Context.View.GetFeatureLevel());
|
|
if (Material->NeedsGBuffer())
|
|
{
|
|
// AdjustGBufferRefCount(-1) call is done when the pass gets executed
|
|
FSceneRenderTargets::Get(Context.RHICmdList).AdjustGBufferRefCount(Context.RHICmdList, 1);
|
|
}
|
|
|
|
if (BaseFilename.Len())
|
|
{
|
|
// First off, allow the user to specify the pass as a format arg (using {material})
|
|
TMap<FString, FStringFormatArg> FormatMappings;
|
|
FormatMappings.Add(TEXT("material"), (*It)->GetName());
|
|
|
|
FString MaterialFilename = FString::Format(*BaseFilename, FormatMappings);
|
|
|
|
// If the format made no change to the string, we add the name of the material to ensure uniqueness
|
|
if (MaterialFilename == BaseFilename)
|
|
{
|
|
MaterialFilename = BaseFilename + TEXT("_") + (*It)->GetName();
|
|
}
|
|
|
|
MaterialFilename.Append(TEXT(".png"));
|
|
MaterialPass->SetOutputDumpFilename(ePId_Output0, *MaterialFilename);
|
|
}
|
|
|
|
// If the overview mode is activated, downsample the material pass to quarter size
|
|
if (bOverviewModeEnabled)
|
|
{
|
|
// Down-sample to 1/2 size
|
|
FRenderingCompositePass* HalfSize = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDownsample(PF_Unknown, 0, TEXT("MaterialHalfSize")));
|
|
HalfSize->SetInput(ePId_Input0, FRenderingCompositeOutputRef(MaterialPass));
|
|
|
|
// Down-sample to 1/4 size
|
|
FRenderingCompositePass* QuarterSize = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDownsample(PF_Unknown, 0, TEXT("MaterialQuarterSize")));
|
|
QuarterSize->SetInput(ePId_Input0, FRenderingCompositeOutputRef(HalfSize));
|
|
|
|
// Mark the quarter size target as the dependency for the composite pass
|
|
((FRCPassPostProcessVisualizeBuffer*)CompositePass)->AddVisualizationBuffer(FRenderingCompositeOutputRef(QuarterSize), (*It)->GetName());
|
|
}
|
|
else
|
|
{
|
|
// We are just dumping the frames, so the material pass is the dependency of the composite
|
|
CompositePass->AddDependency(MaterialPass);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bOverviewModeEnabled)
|
|
{
|
|
((FRCPassPostProcessVisualizeBuffer*)CompositePass)->AddVisualizationBuffer(FRenderingCompositeOutputRef(), FString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// could be moved into the graph
|
|
// allows for Framebuffer blending optimization with the composition graph
|
|
void OverrideRenderTarget(FRenderingCompositeOutputRef It, TRefCountPtr<IPooledRenderTarget>& RT, FPooledRenderTargetDesc& Desc)
|
|
{
|
|
for(;;)
|
|
{
|
|
It.GetOutput()->PooledRenderTarget = RT;
|
|
It.GetOutput()->RenderTargetDesc = Desc;
|
|
|
|
if(!It.GetPass()->FrameBufferBlendingWithInput0())
|
|
{
|
|
break;
|
|
}
|
|
|
|
It = *It.GetPass()->GetInput(ePId_Input0);
|
|
}
|
|
}
|
|
|
|
bool FPostProcessing::AllowFullPostProcessing(const FViewInfo& View, ERHIFeatureLevel::Type FeatureLevel)
|
|
{
|
|
return View.Family->EngineShowFlags.PostProcessing
|
|
&& FeatureLevel >= ERHIFeatureLevel::SM4
|
|
&& !View.Family->EngineShowFlags.VisualizeDistanceFieldAO
|
|
&& !View.Family->EngineShowFlags.VisualizeDistanceFieldGI
|
|
&& !View.Family->EngineShowFlags.VisualizeShadingModels
|
|
&& !View.Family->EngineShowFlags.VisualizeMeshDistanceFields;
|
|
}
|
|
|
|
void FPostProcessing::Process(FRHICommandListImmediate& RHICmdList, const FViewInfo& View, TRefCountPtr<IPooledRenderTarget>& VelocityRT)
|
|
{
|
|
QUICK_SCOPE_CYCLE_COUNTER( STAT_PostProcessing_Process );
|
|
|
|
check(IsInRenderingThread());
|
|
|
|
const auto FeatureLevel = View.GetFeatureLevel();
|
|
|
|
GRenderTargetPool.AddPhaseEvent(TEXT("PostProcessing"));
|
|
|
|
// This page: https://udn.epicgames.com/Three/RenderingOverview#Rendering%20state%20defaults
|
|
// describes what state a pass can expect and to what state it need to be set back.
|
|
|
|
// All post processing is happening on the render thread side. All passes can access FinalPostProcessSettings and all
|
|
// view settings. Those are copies for the RT then never get access by the main thread again.
|
|
// Pointers to other structures might be unsafe to touch.
|
|
|
|
|
|
// so that the passes can register themselves to the graph
|
|
{
|
|
FMemMark Mark(FMemStack::Get());
|
|
FRenderingCompositePassContext CompositeContext(RHICmdList, View);
|
|
|
|
FPostprocessContext Context(RHICmdList, CompositeContext.Graph, View);
|
|
|
|
// not always valid
|
|
FRenderingCompositeOutputRef HistogramOverScreen;
|
|
FRenderingCompositeOutputRef Histogram;
|
|
FRenderingCompositeOutputRef PreTonemapHDRColor;
|
|
FRenderingCompositeOutputRef PostTonemapHDRColor;
|
|
|
|
class FAutoExposure
|
|
{
|
|
public:
|
|
FAutoExposure(const FViewInfo& InView) :
|
|
MethodId(GetAutoExposureMethod(InView))
|
|
{}
|
|
// distinguish between Basic and Histogram-based
|
|
EAutoExposureMethod MethodId;
|
|
// not always valid
|
|
FRenderingCompositeOutputRef EyeAdaptation;
|
|
} AutoExposure(View);
|
|
|
|
// not always valid
|
|
FRenderingCompositeOutputRef SeparateTranslucency;
|
|
// optional
|
|
FRenderingCompositeOutputRef BloomOutputCombined;
|
|
// not always valid
|
|
FRenderingCompositePass* VelocityFlattenPass = 0;
|
|
// in the following code some feature might set this to false
|
|
bool bAllowTonemapper = FeatureLevel >= ERHIFeatureLevel::SM4;
|
|
//
|
|
bool bStereoRenderingAndHMD = View.Family->EngineShowFlags.StereoRendering && View.Family->EngineShowFlags.HMDDistortion;
|
|
//
|
|
FRCPassPostProcessUpscale::PaniniParams PaniniConfig(View);
|
|
//
|
|
EStereoscopicPass StereoPass = View.StereoPass;
|
|
//
|
|
FSceneViewState* ViewState = (FSceneViewState*)Context.View.State;
|
|
//
|
|
bool bDoScreenPercentage;
|
|
{
|
|
//
|
|
bool bHMDWantsUpscale = bStereoRenderingAndHMD && GEngine->HMDDevice->NeedsUpscalePostProcessPass();
|
|
// Do not use upscale if SeparateRenderTarget is in use! (stereo rendering wants to control this)
|
|
bool bAllowScreenPercentage = bHMDWantsUpscale || !View.Family->EngineShowFlags.StereoRendering || (!View.Family->EngineShowFlags.HMDDistortion && !View.Family->bUseSeparateRenderTarget);
|
|
// is Upscale from a lower resolution needed and allowed
|
|
bDoScreenPercentage = bAllowScreenPercentage && (View.UnscaledViewRect != View.ViewRect);
|
|
}
|
|
|
|
{
|
|
if (FSceneRenderTargets::Get(RHICmdList).SeparateTranslucencyRT)
|
|
{
|
|
FRenderingCompositePass* NodeSeparateTranslucency = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(FSceneRenderTargets::Get(RHICmdList).SeparateTranslucencyRT));
|
|
SeparateTranslucency = FRenderingCompositeOutputRef(NodeSeparateTranslucency);
|
|
|
|
// make sure we only release if this is the last view we're rendering
|
|
int32 LastView = View.Family->Views.Num() - 1;
|
|
if (View.Family->Views[LastView] == &View)
|
|
{
|
|
// the node keeps another reference so the RT will not be release too early
|
|
FSceneRenderTargets::Get(RHICmdList).FreeSeparateTranslucency();
|
|
check(!FSceneRenderTargets::Get(RHICmdList).SeparateTranslucencyRT);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool bVisualizeHDR = View.Family->EngineShowFlags.VisualizeHDR && FeatureLevel >= ERHIFeatureLevel::SM5;
|
|
bool bVisualizeBloom = View.Family->EngineShowFlags.VisualizeBloom && FeatureLevel >= ERHIFeatureLevel::SM4;
|
|
bool bVisualizeMotionBlur = View.Family->EngineShowFlags.VisualizeMotionBlur && FeatureLevel >= ERHIFeatureLevel::SM4;
|
|
|
|
if(bVisualizeHDR || bVisualizeBloom || bVisualizeMotionBlur)
|
|
{
|
|
bAllowTonemapper = false;
|
|
}
|
|
|
|
static const auto CVarHDROutputEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.HDR.EnableHDROutput"));
|
|
const bool bHDROutputEnabled = GRHISupportsHDROutput && CVarHDROutputEnabled->GetValueOnRenderThread() != 0;
|
|
|
|
static const auto CVarDumpFramesAsHDR = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.BufferVisualizationDumpFramesAsHDR"));
|
|
const bool bHDRTonemapperOutput = bAllowTonemapper && (GetHighResScreenshotConfig().bCaptureHDR || CVarDumpFramesAsHDR->GetValueOnRenderThread() || bHDROutputEnabled);
|
|
|
|
FRCPassPostProcessTonemap* Tonemapper = 0;
|
|
|
|
// add the passes we want to add to the graph (commenting a line means the pass is not inserted into the graph) ---------
|
|
|
|
if (AllowFullPostProcessing(View, FeatureLevel))
|
|
{
|
|
FRenderingCompositeOutputRef VelocityInput;
|
|
if(VelocityRT)
|
|
{
|
|
VelocityInput = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(VelocityRT));
|
|
}
|
|
|
|
AddPostProcessMaterial(Context, BL_BeforeTranslucency, SeparateTranslucency);
|
|
|
|
static const auto CVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DepthOfFieldQuality"));
|
|
check(CVar)
|
|
bool bDepthOfField = View.Family->EngineShowFlags.DepthOfField && CVar->GetValueOnRenderThread() > 0;
|
|
|
|
FDepthOfFieldStats DepthOfFieldStat;
|
|
|
|
bool bSepTransWasApplied = false;
|
|
|
|
if(bDepthOfField && View.FinalPostProcessSettings.DepthOfFieldMethod != DOFM_BokehDOF)
|
|
{
|
|
bool bCircleDOF = View.FinalPostProcessSettings.DepthOfFieldMethod == DOFM_CircleDOF;
|
|
if(!bCircleDOF)
|
|
{
|
|
check(!SupportSceneAlpha());
|
|
if(VelocityInput.IsValid())
|
|
{
|
|
bSepTransWasApplied = AddPostProcessDepthOfFieldGaussian(Context, DepthOfFieldStat, VelocityInput, SeparateTranslucency);
|
|
}
|
|
else
|
|
{
|
|
// todo: black/white default is a compositing graph feature, no need to hook up a node
|
|
|
|
// black is how we clear the velocity buffer so this means no velocity
|
|
FRenderingCompositePass* NoVelocity = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(GSystemTextures.BlackDummy));
|
|
FRenderingCompositeOutputRef NoVelocityRef(NoVelocity);
|
|
bSepTransWasApplied = AddPostProcessDepthOfFieldGaussian(Context, DepthOfFieldStat, NoVelocityRef, SeparateTranslucency);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(VelocityInput.IsValid())
|
|
{
|
|
AddPostProcessDepthOfFieldCircle(Context, DepthOfFieldStat, VelocityInput);
|
|
}
|
|
else
|
|
{
|
|
// todo: black/white default is a compositing graph feature, no need to hook up a node
|
|
|
|
// black is how we clear the velocity buffer so this means no velocity
|
|
FRenderingCompositePass* NoVelocity = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(GSystemTextures.BlackDummy));
|
|
FRenderingCompositeOutputRef NoVelocityRef(NoVelocity);
|
|
AddPostProcessDepthOfFieldCircle(Context, DepthOfFieldStat, NoVelocityRef);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool bBokehDOF = bDepthOfField
|
|
&& View.FinalPostProcessSettings.DepthOfFieldScale > 0
|
|
&& View.FinalPostProcessSettings.DepthOfFieldMethod == DOFM_BokehDOF
|
|
&& !Context.View.Family->EngineShowFlags.VisualizeDOF;
|
|
|
|
if(bBokehDOF)
|
|
{
|
|
check(!SupportSceneAlpha());
|
|
if(VelocityInput.IsValid())
|
|
{
|
|
AddPostProcessDepthOfFieldBokeh(Context, SeparateTranslucency, VelocityInput);
|
|
}
|
|
else
|
|
{
|
|
// todo: black/white default is a compositing graph feature, no need to hook up a node
|
|
|
|
// black is how we clear the velocity buffer so this means no velocity
|
|
FRenderingCompositePass* NoVelocity = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(GSystemTextures.BlackDummy));
|
|
FRenderingCompositeOutputRef NoVelocityRef(NoVelocity);
|
|
AddPostProcessDepthOfFieldBokeh(Context, SeparateTranslucency, NoVelocityRef);
|
|
}
|
|
bSepTransWasApplied = true;
|
|
}
|
|
|
|
if(SeparateTranslucency.IsValid() && !bSepTransWasApplied)
|
|
{
|
|
check(!SupportSceneAlpha());
|
|
// separate translucency is done here or in AddPostProcessDepthOfFieldBokeh()
|
|
FRenderingCompositePass* NodeRecombined = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBokehDOFRecombine());
|
|
NodeRecombined->SetInput(ePId_Input0, Context.FinalOutput);
|
|
NodeRecombined->SetInput(ePId_Input2, SeparateTranslucency);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(NodeRecombined);
|
|
}
|
|
|
|
AddPostProcessMaterial(Context, BL_BeforeTonemapping, SeparateTranslucency);
|
|
|
|
EAntiAliasingMethod AntiAliasingMethod = Context.View.AntiAliasingMethod;
|
|
|
|
if( AntiAliasingMethod == AAM_TemporalAA && ViewState)
|
|
{
|
|
if(VelocityInput.IsValid())
|
|
{
|
|
AddTemporalAA( Context, VelocityInput );
|
|
}
|
|
else
|
|
{
|
|
// black is how we clear the velocity buffer so this means no velocity
|
|
FRenderingCompositePass* NoVelocity = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(GSystemTextures.BlackDummy));
|
|
FRenderingCompositeOutputRef NoVelocityRef(NoVelocity);
|
|
AddTemporalAA( Context, NoVelocityRef );
|
|
}
|
|
}
|
|
|
|
if(IsMotionBlurEnabled(View) && VelocityInput.IsValid() && !bVisualizeMotionBlur)
|
|
{
|
|
// Motion blur
|
|
|
|
FRenderingCompositeOutputRef MaxTileVelocity;
|
|
|
|
{
|
|
check(!VelocityFlattenPass);
|
|
VelocityFlattenPass = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessVelocityFlatten() );
|
|
VelocityFlattenPass->SetInput( ePId_Input0, VelocityInput );
|
|
VelocityFlattenPass->SetInput( ePId_Input1, Context.SceneDepth );
|
|
|
|
VelocityInput = FRenderingCompositeOutputRef( VelocityFlattenPass, ePId_Output0 );
|
|
MaxTileVelocity = FRenderingCompositeOutputRef( VelocityFlattenPass, ePId_Output1 );
|
|
}
|
|
|
|
const float SizeX = View.ViewRect.Width();
|
|
|
|
// 0:no 1:full screen width, percent conversion
|
|
float MaxVelocity = View.FinalPostProcessSettings.MotionBlurMax / 100.0f;
|
|
float MaxVelocityTiles = MaxVelocity * SizeX * (0.5f / 16.0f);
|
|
float MaxTileDistGathered = 3.0f;
|
|
if( MaxVelocityTiles > MaxTileDistGathered || CVarMotionBlurScatter.GetValueOnRenderThread() || (ViewState && ViewState->bSequencerIsPaused) )
|
|
{
|
|
FRenderingCompositePass* VelocityScatterPass = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessVelocityScatter() );
|
|
VelocityScatterPass->SetInput( ePId_Input0, MaxTileVelocity );
|
|
|
|
MaxTileVelocity = FRenderingCompositeOutputRef( VelocityScatterPass );
|
|
}
|
|
else
|
|
{
|
|
FRenderingCompositePass* VelocityGatherPass = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessVelocityGather() );
|
|
VelocityGatherPass->SetInput( ePId_Input0, MaxTileVelocity );
|
|
|
|
MaxTileVelocity = FRenderingCompositeOutputRef( VelocityGatherPass );
|
|
}
|
|
|
|
bool bTwoPass = CVarMotionBlurSeparable.GetValueOnRenderThread() != 0;
|
|
{
|
|
FRenderingCompositePass* MotionBlurPass = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessMotionBlur( GetMotionBlurQualityFromCVar(), bTwoPass ? 0 : -1 ) );
|
|
MotionBlurPass->SetInput( ePId_Input0, Context.FinalOutput );
|
|
MotionBlurPass->SetInput( ePId_Input1, Context.SceneDepth );
|
|
MotionBlurPass->SetInput( ePId_Input2, VelocityInput );
|
|
MotionBlurPass->SetInput( ePId_Input3, MaxTileVelocity );
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef( MotionBlurPass );
|
|
}
|
|
|
|
if( bTwoPass )
|
|
{
|
|
FRenderingCompositePass* MotionBlurPass = Context.Graph.RegisterPass( new(FMemStack::Get()) FRCPassPostProcessMotionBlur( GetMotionBlurQualityFromCVar(), 1 ) );
|
|
MotionBlurPass->SetInput( ePId_Input0, Context.FinalOutput );
|
|
MotionBlurPass->SetInput( ePId_Input1, Context.SceneDepth );
|
|
MotionBlurPass->SetInput( ePId_Input2, VelocityInput );
|
|
MotionBlurPass->SetInput( ePId_Input3, MaxTileVelocity );
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef( MotionBlurPass );
|
|
}
|
|
}
|
|
|
|
if(VelocityInput.IsValid() && bVisualizeMotionBlur)
|
|
{
|
|
auto VisualizePass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeMotionBlur());
|
|
VisualizePass->SetInput(ePId_Input0, Context.FinalOutput);
|
|
VisualizePass->SetInput(ePId_Input1, Context.SceneDepth);
|
|
VisualizePass->SetInput(ePId_Input2, VelocityInput);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(VisualizePass);
|
|
}
|
|
|
|
if(bVisualizeBloom)
|
|
{
|
|
AddVisualizeBloomSetup(Context);
|
|
}
|
|
|
|
// down sample Scene color from full to half res
|
|
FRenderingCompositeOutputRef SceneColorHalfRes;
|
|
{
|
|
int32 DownsampleQuality = FMath::Clamp(CDownsampleQuality.GetValueOnRenderThread(), 0, 1);
|
|
|
|
// doesn't have to be as high quality as the Scene color
|
|
FRenderingCompositePass* HalfResPass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDownsample(PF_FloatRGB, DownsampleQuality, TEXT("SceneColorHalfRes")));
|
|
HalfResPass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
|
|
SceneColorHalfRes = FRenderingCompositeOutputRef(HalfResPass);
|
|
}
|
|
|
|
{
|
|
bool bHistogramNeeded = false;
|
|
|
|
if (View.Family->EngineShowFlags.EyeAdaptation && (AutoExposure.MethodId == EAutoExposureMethod::AEM_Histogram)
|
|
&& View.FinalPostProcessSettings.AutoExposureMinBrightness < View.FinalPostProcessSettings.AutoExposureMaxBrightness
|
|
&& !View.bIsSceneCapture // Eye adaption is not available for scene captures.
|
|
&& !bVisualizeBloom)
|
|
{
|
|
bHistogramNeeded = true;
|
|
}
|
|
|
|
if(!bAllowTonemapper)
|
|
{
|
|
bHistogramNeeded = false;
|
|
}
|
|
|
|
if(View.Family->EngineShowFlags.VisualizeHDR)
|
|
{
|
|
bHistogramNeeded = true;
|
|
}
|
|
|
|
if (!GIsHighResScreenshot && bHistogramNeeded && FeatureLevel >= ERHIFeatureLevel::SM5 && StereoPass != eSSP_RIGHT_EYE)
|
|
{
|
|
FRenderingCompositePass* NodeHistogram = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessHistogram());
|
|
|
|
NodeHistogram->SetInput(ePId_Input0, SceneColorHalfRes);
|
|
|
|
HistogramOverScreen = FRenderingCompositeOutputRef(NodeHistogram);
|
|
|
|
FRenderingCompositePass* NodeHistogramReduce = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessHistogramReduce());
|
|
|
|
NodeHistogramReduce->SetInput(ePId_Input0, NodeHistogram);
|
|
|
|
Histogram = FRenderingCompositeOutputRef(NodeHistogramReduce);
|
|
}
|
|
}
|
|
|
|
// Compute DownSamples passes used by bloom, tint and eye-adaptation if possible.
|
|
FBloomDownSampleArray::Ptr BloomAndEyeDownSamplesPtr;
|
|
if (View.FinalPostProcessSettings.BloomIntensity > 0.f) // do bloom
|
|
{
|
|
// No Threshold: We can share with Eye-Adaptation.
|
|
if (Context.View.FinalPostProcessSettings.BloomThreshold <= -1 && Context.View.Family->Views.Num() == 1)
|
|
{
|
|
if (!GIsHighResScreenshot && View.State &&
|
|
(StereoPass != eSSP_RIGHT_EYE) &&
|
|
(AutoExposure.MethodId == EAutoExposureMethod::AEM_Basic))
|
|
{
|
|
BloomAndEyeDownSamplesPtr = CreateDownSampleArray(Context, SceneColorHalfRes, true /*bGenerateLog2Alpha*/);
|
|
}
|
|
}
|
|
}
|
|
|
|
// some views don't have a state (thumbnail rendering)
|
|
if(!GIsHighResScreenshot && View.State && (StereoPass != eSSP_RIGHT_EYE))
|
|
{
|
|
|
|
const bool bUseBasicEyeAdaptation = (AutoExposure.MethodId == EAutoExposureMethod::AEM_Basic);
|
|
|
|
if (bUseBasicEyeAdaptation) // log average ps reduction ( non histogram )
|
|
{
|
|
|
|
if (!BloomAndEyeDownSamplesPtr.IsValid())
|
|
{
|
|
// need downsamples for eye-adaptation.
|
|
FBloomDownSampleArray::Ptr EyeDownSamplesPtr = CreateDownSampleArray(Context, SceneColorHalfRes, true /*bGenerateLog2Alpha*/);
|
|
AutoExposure.EyeAdaptation = AddPostProcessBasicEyeAdaptation(View, *EyeDownSamplesPtr);
|
|
}
|
|
else
|
|
{
|
|
// Use the alpha channel in the last downsample (smallest) to compute eye adaptations values.
|
|
AutoExposure.EyeAdaptation = AddPostProcessBasicEyeAdaptation(View, *BloomAndEyeDownSamplesPtr);
|
|
}
|
|
}
|
|
else // Use histogram version version
|
|
{
|
|
// we always add eye adaptation, if the engine show flag is disabled we set the ExposureScale in the texture to a fixed value
|
|
AutoExposure.EyeAdaptation = AddPostProcessHistogramEyeAdaptation(Context, Histogram);
|
|
}
|
|
}
|
|
|
|
if(View.FinalPostProcessSettings.BloomIntensity > 0.0f)
|
|
{
|
|
if (CVarUseMobileBloom.GetValueOnRenderThread() == 0)
|
|
{
|
|
if (!BloomAndEyeDownSamplesPtr.IsValid())
|
|
{
|
|
FRenderingCompositeOutputRef HalfResBloomThreshold = RenderHalfResBloomThreshold(Context, SceneColorHalfRes, AutoExposure.EyeAdaptation);
|
|
BloomAndEyeDownSamplesPtr = CreateDownSampleArray(Context, HalfResBloomThreshold, false /*bGenerateLog2Alpha*/);
|
|
}
|
|
BloomOutputCombined = AddBloom(*BloomAndEyeDownSamplesPtr, bVisualizeBloom);
|
|
}
|
|
else
|
|
{
|
|
FIntPoint PrePostSourceViewportSize = View.ViewRect.Size();
|
|
|
|
// Bloom.
|
|
FRenderingCompositeOutputRef PostProcessDownsample2;
|
|
FRenderingCompositeOutputRef PostProcessDownsample3;
|
|
FRenderingCompositeOutputRef PostProcessDownsample4;
|
|
FRenderingCompositeOutputRef PostProcessDownsample5;
|
|
FRenderingCompositeOutputRef PostProcessUpsample4;
|
|
FRenderingCompositeOutputRef PostProcessUpsample3;
|
|
FRenderingCompositeOutputRef PostProcessUpsample2;
|
|
FRenderingCompositeOutputRef PostProcessSunMerge;
|
|
|
|
float DownScale = 0.66f * 4.0f;
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/4, DownScale));
|
|
Pass->SetInput(ePId_Input0, SceneColorHalfRes);
|
|
PostProcessDownsample2 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/8, DownScale));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample2);
|
|
PostProcessDownsample3 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/16, DownScale));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample3);
|
|
PostProcessDownsample4 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/32, DownScale));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample4);
|
|
PostProcessDownsample5 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
const FFinalPostProcessSettings& Settings = Context.View.FinalPostProcessSettings;
|
|
|
|
float UpScale = 0.66f * 2.0f;
|
|
// Upsample by 2
|
|
{
|
|
FVector4 TintA = FVector4(Settings.Bloom4Tint.R, Settings.Bloom4Tint.G, Settings.Bloom4Tint.B, 0.0f);
|
|
FVector4 TintB = FVector4(Settings.Bloom5Tint.R, Settings.Bloom5Tint.G, Settings.Bloom5Tint.B, 0.0f);
|
|
TintA *= View.FinalPostProcessSettings.BloomIntensity;
|
|
TintB *= View.FinalPostProcessSettings.BloomIntensity;
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomUpES2(PrePostSourceViewportSize/32, FVector2D(UpScale, UpScale), TintA, TintB));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample4);
|
|
Pass->SetInput(ePId_Input1, PostProcessDownsample5);
|
|
PostProcessUpsample4 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Upsample by 2
|
|
{
|
|
FVector4 TintA = FVector4(Settings.Bloom3Tint.R, Settings.Bloom3Tint.G, Settings.Bloom3Tint.B, 0.0f);
|
|
TintA *= View.FinalPostProcessSettings.BloomIntensity;
|
|
FVector4 TintB = FVector4(1.0f, 1.0f, 1.0f, 0.0f);
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomUpES2(PrePostSourceViewportSize/16, FVector2D(UpScale, UpScale), TintA, TintB));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample3);
|
|
Pass->SetInput(ePId_Input1, PostProcessUpsample4);
|
|
PostProcessUpsample3 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Upsample by 2
|
|
{
|
|
FVector4 TintA = FVector4(Settings.Bloom2Tint.R, Settings.Bloom2Tint.G, Settings.Bloom2Tint.B, 0.0f);
|
|
TintA *= View.FinalPostProcessSettings.BloomIntensity;
|
|
// Scaling Bloom2 by extra factor to match filter area difference between PC default and mobile.
|
|
TintA *= 0.5;
|
|
FVector4 TintB = FVector4(1.0f, 1.0f, 1.0f, 0.0f);
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomUpES2(PrePostSourceViewportSize/8, FVector2D(UpScale, UpScale), TintA, TintB));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample2);
|
|
Pass->SetInput(ePId_Input1, PostProcessUpsample3);
|
|
PostProcessUpsample2 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSunMergeES2(PrePostSourceViewportSize));
|
|
Pass->SetInput(ePId_Input1, SceneColorHalfRes);
|
|
Pass->SetInput(ePId_Input2, PostProcessUpsample2);
|
|
PostProcessSunMerge = FRenderingCompositeOutputRef(Pass);
|
|
BloomOutputCombined = PostProcessSunMerge;
|
|
}
|
|
}
|
|
}
|
|
|
|
PreTonemapHDRColor = Context.FinalOutput;
|
|
|
|
if(bAllowTonemapper)
|
|
{
|
|
auto Node = AddSinglePostProcessMaterial(Context, BL_ReplacingTonemapper);
|
|
|
|
if(Node)
|
|
{
|
|
// a custom tonemapper is provided
|
|
Node->SetInput(ePId_Input0, Context.FinalOutput);
|
|
|
|
// We are binding separate translucency here because the post process SceneTexture node can reference
|
|
// the separate translucency buffers through ePId_Input1.
|
|
// TODO: Check if material actually uses this texture and only bind if needed.
|
|
Node->SetInput(ePId_Input1, SeparateTranslucency);
|
|
Node->SetInput(ePId_Input2, BloomOutputCombined);
|
|
Context.FinalOutput = Node;
|
|
}
|
|
else
|
|
{
|
|
Tonemapper = AddTonemapper(Context, BloomOutputCombined, AutoExposure.EyeAdaptation, AutoExposure.MethodId, false, bHDRTonemapperOutput);
|
|
}
|
|
|
|
PostTonemapHDRColor = Context.FinalOutput;
|
|
|
|
// Add a pass-through as tonemapper will be forced LDR if final pass in chain
|
|
if (bHDRTonemapperOutput && !bHDROutputEnabled)
|
|
{
|
|
FRenderingCompositePass* PassthroughNode = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessPassThrough(nullptr));
|
|
PassthroughNode->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(PassthroughNode);
|
|
}
|
|
}
|
|
|
|
if(AntiAliasingMethod == AAM_FXAA)
|
|
{
|
|
AddPostProcessAA(Context);
|
|
}
|
|
|
|
if(bDepthOfField && Context.View.Family->EngineShowFlags.VisualizeDOF)
|
|
{
|
|
FRenderingCompositePass* VisualizeNode = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeDOF(DepthOfFieldStat));
|
|
VisualizeNode->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(VisualizeNode);
|
|
bAllowTonemapper = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (SeparateTranslucency.IsValid())
|
|
{
|
|
// separate translucency is done here or in AddPostProcessDepthOfFieldBokeh()
|
|
FRenderingCompositePass* NodeRecombined = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBokehDOFRecombine());
|
|
NodeRecombined->SetInput(ePId_Input0, Context.FinalOutput);
|
|
NodeRecombined->SetInput(ePId_Input2, SeparateTranslucency);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(NodeRecombined);
|
|
}
|
|
|
|
// Shader complexity does not actually output a color
|
|
if (!View.Family->EngineShowFlags.ShaderComplexity)
|
|
{
|
|
AddGammaOnlyTonemapper(Context);
|
|
}
|
|
}
|
|
|
|
bool bResultsUpsampled = false;
|
|
if(View.Family->EngineShowFlags.StationaryLightOverlap)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeComplexity(GEngine->StationaryLightOverlapColors, FVisualizeComplexityApplyPS::CS_RAMP, 1.f, false));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.SceneColor));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
bResultsUpsampled = true;
|
|
}
|
|
|
|
const EDebugViewShaderMode DebugViewShaderMode = View.Family->GetDebugViewShaderMode();
|
|
if(DebugViewShaderMode == DVSM_QuadComplexity)
|
|
{
|
|
float ComplexityScale = 1.f / (float)(GEngine->QuadComplexityColors.Num() - 1) / NormalizedQuadComplexityValue; // .1f comes from the values used in LightAccumulator_GetResult
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeComplexity(GEngine->QuadComplexityColors, FVisualizeComplexityApplyPS::CS_STAIR, ComplexityScale, true));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
bResultsUpsampled = true;
|
|
}
|
|
|
|
if(DebugViewShaderMode == DVSM_ShaderComplexity || DebugViewShaderMode == DVSM_ShaderComplexityContainedQuadOverhead || DebugViewShaderMode == DVSM_ShaderComplexityBleedingQuadOverhead)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeComplexity(GEngine->ShaderComplexityColors, FVisualizeComplexityApplyPS::CS_RAMP, 1.f, true));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
bResultsUpsampled = true;
|
|
}
|
|
|
|
if (DebugViewShaderMode == DVSM_PrimitiveDistanceAccuracy || DebugViewShaderMode == DVSM_MeshUVDensityAccuracy || DebugViewShaderMode == DVSM_MaterialTextureScaleAccuracy ||DebugViewShaderMode == DVSM_RequiredTextureResolution)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessStreamingAccuracyLegend(GEngine->StreamingAccuracyColors));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
bResultsUpsampled = true;
|
|
}
|
|
|
|
if(View.Family->EngineShowFlags.VisualizeLightCulling)
|
|
{
|
|
float ComplexityScale = 1.f / (float)(GEngine->LightComplexityColors.Num() - 1) / .1f; // .1f comes from the values used in LightAccumulator_GetResult
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeComplexity(GEngine->LightComplexityColors, FVisualizeComplexityApplyPS::CS_LINEAR, ComplexityScale, false));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.SceneColor));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
bResultsUpsampled = true;
|
|
}
|
|
|
|
if(View.Family->EngineShowFlags.VisualizeLPV && !View.Family->EngineShowFlags.VisualizeHDR)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeLPV());
|
|
Node->SetInput(ePId_Input0, Context.FinalOutput);
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
bResultsUpsampled = true;
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
// Show the selection outline if it is in the editor and we aren't in wireframe
|
|
// If the engine is in demo mode and game view is on we also do not show the selection outline
|
|
if ( GIsEditor
|
|
&& View.Family->EngineShowFlags.SelectionOutline
|
|
&& !(View.Family->EngineShowFlags.Wireframe)
|
|
&& ( !GIsDemoMode || ( GIsDemoMode && !View.Family->EngineShowFlags.Game ) )
|
|
&& !bVisualizeBloom
|
|
&& !View.Family->EngineShowFlags.VisualizeHDR)
|
|
{
|
|
// Selection outline is after bloom, but before AA
|
|
AddSelectionOutline(Context);
|
|
}
|
|
|
|
// Composite editor primitives if we had any to draw and compositing is enabled
|
|
if (FSceneRenderer::ShouldCompositeEditorPrimitives(View) && !bVisualizeBloom)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessCompositeEditorPrimitives(true));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
#endif
|
|
if(View.Family->EngineShowFlags.VisualizeShadingModels && FeatureLevel >= ERHIFeatureLevel::SM4)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeShadingModels(RHICmdList));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
if (View.Family->EngineShowFlags.GBufferHints && FeatureLevel >= ERHIFeatureLevel::SM4)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessGBufferHints(RHICmdList));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
// Ideally without lighting as we want the emissive, we should do that later.
|
|
Node->SetInput(ePId_Input1, FRenderingCompositeOutputRef(Context.SceneColor));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
AddPostProcessMaterial(Context, BL_AfterTonemapping, SeparateTranslucency, PreTonemapHDRColor, PostTonemapHDRColor);
|
|
|
|
#if WITH_EDITOR
|
|
//Inspect the Final color, GBuffer and HDR
|
|
//No more postprocess Final color should be the real one
|
|
//The HDR was save before the tonemapping
|
|
//GBuffer should not be change during post process
|
|
if (View.bUsePixelInspector && FeatureLevel >= ERHIFeatureLevel::SM4)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBufferInspector(RHICmdList));
|
|
Node->SetInput(ePId_Input0, Context.FinalOutput);
|
|
Node->SetInput(ePId_Input1, PreTonemapHDRColor);
|
|
Node->SetInput(ePId_Input2, Context.SceneColor);
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
#endif //WITH_EDITOR
|
|
|
|
if(bVisualizeBloom)
|
|
{
|
|
AddVisualizeBloomOverlay(Context, PreTonemapHDRColor, BloomOutputCombined);
|
|
}
|
|
|
|
if (View.Family->EngineShowFlags.VisualizeSSS)
|
|
{
|
|
// the setup pass also does visualization, based on EngineShowFlags.VisualizeSSS
|
|
FRenderingCompositePass* PassVisualize = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSubsurfaceVisualize(RHICmdList));
|
|
PassVisualize->SetInput(ePId_Input0, Context.FinalOutput);
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(PassVisualize);
|
|
}
|
|
|
|
AddGBufferVisualizationOverview(Context, SeparateTranslucency, PreTonemapHDRColor, PostTonemapHDRColor);
|
|
|
|
if (bStereoRenderingAndHMD)
|
|
{
|
|
FRenderingCompositePass* Node = NULL;
|
|
const EHMDDeviceType::Type DeviceType = GEngine->HMDDevice->GetHMDDeviceType();
|
|
if((DeviceType == EHMDDeviceType::DT_OculusRift) || (DeviceType == EHMDDeviceType::DT_GoogleVR))
|
|
{
|
|
Node = Context.Graph.RegisterPass(new FRCPassPostProcessHMD());
|
|
}
|
|
else if(DeviceType == EHMDDeviceType::DT_Morpheus)
|
|
{
|
|
|
|
#if MORPHEUS_ENGINE_DISTORTION
|
|
FRCPassPostProcessMorpheus* MorpheusPass = new FRCPassPostProcessMorpheus();
|
|
MorpheusPass->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Node = Context.Graph.RegisterPass(MorpheusPass);
|
|
#endif
|
|
}
|
|
|
|
if(Node)
|
|
{
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
}
|
|
|
|
if(bVisualizeHDR)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeHDR());
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Node->SetInput(ePId_Input1, Histogram);
|
|
Node->SetInput(ePId_Input2, PreTonemapHDRColor);
|
|
Node->SetInput(ePId_Input3, HistogramOverScreen);
|
|
Node->AddDependency(AutoExposure.EyeAdaptation);
|
|
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
if(View.Family->EngineShowFlags.TestImage && FeatureLevel >= ERHIFeatureLevel::SM4)
|
|
{
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessTestImage());
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
AddHighResScreenshotMask(Context, SeparateTranslucency);
|
|
|
|
if(bDoScreenPercentage && !bResultsUpsampled)
|
|
{
|
|
// Check if we can save the Upscale pass and do it in the Tonemapper to save performance
|
|
if(Tonemapper && !PaniniConfig.IsEnabled() && !Tonemapper->bDoGammaOnly)
|
|
{
|
|
if (Context.FinalOutput.GetPass() == Tonemapper)
|
|
{
|
|
const int32 TonemapperMergeMode = CVarTonemapperMergeMode.GetValueOnRenderThread();
|
|
bool bCombineTonemapperAndUpsample = false;
|
|
|
|
if (TonemapperMergeMode == 1)
|
|
{
|
|
bCombineTonemapperAndUpsample = true;
|
|
}
|
|
else if (TonemapperMergeMode == 2)
|
|
{
|
|
const float TonemapperMergeThreshold = CVarTonemapperMergeThreshold.GetValueOnRenderThread();
|
|
const float AreaRatio = View.ViewRect.Area() / (float)View.UnscaledViewRect.Area();
|
|
bCombineTonemapperAndUpsample = AreaRatio > TonemapperMergeThreshold;
|
|
}
|
|
|
|
if (bCombineTonemapperAndUpsample)
|
|
{
|
|
Tonemapper->bDoScreenPercentageInTonemapper = true;
|
|
// the following pass is no longer needed
|
|
bDoScreenPercentage = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (PaniniConfig.IsEnabled() || bDoScreenPercentage)
|
|
{
|
|
int32 UpscaleQuality = CVarUpscaleQuality.GetValueOnRenderThread();
|
|
UpscaleQuality = FMath::Clamp(UpscaleQuality, 0, 3);
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessUpscale(UpscaleQuality, PaniniConfig));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput)); // Bilinear sampling.
|
|
Node->SetInput(ePId_Input1, FRenderingCompositeOutputRef(Context.FinalOutput)); // Point sampling.
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
}
|
|
|
|
// After the graph is built but before the graph is processed.
|
|
// If a postprocess material is using a GBuffer it adds the refcount int FRCPassPostProcessMaterial::Process()
|
|
// and when it gets processed it removes the refcount
|
|
// We only release the GBuffers after the last view was processed (SplitScreen)
|
|
if(View.Family->Views[View.Family->Views.Num() - 1] == &View)
|
|
{
|
|
// Generally we no longer need the GBuffers, anyone that wants to keep the GBuffers for longer should have called AdjustGBufferRefCount(1) to keep it for longer
|
|
// and call AdjustGBufferRefCount(-1) once it's consumed. This needs to happen each frame. PostProcessMaterial do that automatically
|
|
FSceneRenderTargets::Get(RHICmdList).AdjustGBufferRefCount(RHICmdList, -1);
|
|
}
|
|
|
|
// The graph setup should be finished before this line ----------------------------------------
|
|
{
|
|
// currently created on the heap each frame but View.Family->RenderTarget could keep this object and all would be cleaner
|
|
TRefCountPtr<IPooledRenderTarget> Temp;
|
|
FSceneRenderTargetItem Item;
|
|
Item.TargetableTexture = (FTextureRHIRef&)View.Family->RenderTarget->GetRenderTargetTexture();
|
|
Item.ShaderResourceTexture = (FTextureRHIRef&)View.Family->RenderTarget->GetRenderTargetTexture();
|
|
|
|
FPooledRenderTargetDesc Desc;
|
|
|
|
// Texture could be bigger than viewport
|
|
if (View.Family->RenderTarget->GetRenderTargetTexture())
|
|
{
|
|
Desc.Extent.X = View.Family->RenderTarget->GetRenderTargetTexture()->GetSizeX();
|
|
Desc.Extent.Y = View.Family->RenderTarget->GetRenderTargetTexture()->GetSizeY();
|
|
}
|
|
else
|
|
{
|
|
Desc.Extent = View.Family->RenderTarget->GetSizeXY();
|
|
}
|
|
|
|
// todo: this should come from View.Family->RenderTarget
|
|
Desc.Format = bHDROutputEnabled ? GRHIHDRDisplayOutputFormat : PF_B8G8R8A8;
|
|
Desc.NumMips = 1;
|
|
Desc.DebugName = TEXT("FinalPostProcessColor");
|
|
|
|
GRenderTargetPool.CreateUntrackedElement(Desc, Temp, Item);
|
|
|
|
OverrideRenderTarget(Context.FinalOutput, Temp, Desc);
|
|
|
|
// execute the graph/DAG
|
|
CompositeContext.Process(Context.FinalOutput.GetPass(), TEXT("PostProcessing"));
|
|
}
|
|
}
|
|
|
|
GRenderTargetPool.AddPhaseEvent(TEXT("AfterPostprocessing"));
|
|
}
|
|
|
|
static bool IsGaussianActive(FPostprocessContext& Context)
|
|
{
|
|
|
|
float FarSize = Context.View.FinalPostProcessSettings.DepthOfFieldFarBlurSize;
|
|
float NearSize = Context.View.FinalPostProcessSettings.DepthOfFieldNearBlurSize;
|
|
|
|
float MaxSize = CVarDepthOfFieldMaxSize.GetValueOnRenderThread();
|
|
|
|
FarSize = FMath::Min(FarSize, MaxSize);
|
|
NearSize = FMath::Min(NearSize, MaxSize);
|
|
const float CVarThreshold = CVarDepthOfFieldNearBlurSizeThreshold.GetValueOnRenderThread();
|
|
|
|
if ((FarSize < 0.01f) && (NearSize < CVarThreshold))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void FPostProcessing::ProcessES2(FRHICommandListImmediate& RHICmdList, const FViewInfo& View, bool bUsedFramebufferFetch)
|
|
{
|
|
check(IsInRenderingThread());
|
|
|
|
// This page: https://udn.epicgames.com/Three/RenderingOverview#Rendering%20state%20defaults
|
|
// describes what state a pass can expect and to what state it need to be set back.
|
|
|
|
// All post processing is happening on the render thread side. All passes can access FinalPostProcessSettings and all
|
|
// view settings. Those are copies for the RT then never get access by the main thread again.
|
|
// Pointers to other structures might be unsafe to touch.
|
|
|
|
|
|
// so that the passes can register themselves to the graph
|
|
{
|
|
FMemMark Mark(FMemStack::Get());
|
|
FRenderingCompositePassContext CompositeContext(RHICmdList, View);
|
|
|
|
FPostprocessContext Context(RHICmdList, CompositeContext.Graph, View);
|
|
FRenderingCompositeOutputRef BloomOutput;
|
|
FRenderingCompositeOutputRef DofOutput;
|
|
|
|
bool bUseAa = View.AntiAliasingMethod == AAM_TemporalAA;
|
|
|
|
// AA with Mobile32bpp mode requires this outside of bUsePost.
|
|
if(bUseAa)
|
|
{
|
|
// Handle pointer swap for double buffering.
|
|
FSceneViewState* ViewState = (FSceneViewState*)View.State;
|
|
if(ViewState)
|
|
{
|
|
// Note that this drops references to the render targets from two frames ago. This
|
|
// causes them to be added back to the pool where we can grab them again.
|
|
ViewState->MobileAaBloomSunVignette1 = ViewState->MobileAaBloomSunVignette0;
|
|
ViewState->MobileAaColor1 = ViewState->MobileAaColor0;
|
|
}
|
|
}
|
|
|
|
const FIntPoint FinalTargetSize = View.Family->RenderTarget->GetSizeXY();
|
|
FIntRect FinalOutputViewRect = View.ViewRect;
|
|
FIntPoint PrePostSourceViewportSize = View.ViewRect.Size();
|
|
// ES2 preview uses a subsection of the scene RT, bUsedFramebufferFetch == true deals with this case.
|
|
FIntPoint SceneColorSize = FSceneRenderTargets::Get(RHICmdList).GetBufferSizeXY();
|
|
bool bViewRectSource = bUsedFramebufferFetch || SceneColorSize != PrePostSourceViewportSize;
|
|
|
|
// add the passes we want to add to the graph (commenting a line means the pass is not inserted into the graph) ---------
|
|
if( View.Family->EngineShowFlags.PostProcessing )
|
|
{
|
|
bool bUseMosaic = IsMobileHDRMosaic();
|
|
bool bUseEncodedHDR = IsMobileHDR32bpp() && !bUseMosaic;
|
|
|
|
bool bUseSun = !bUseEncodedHDR && View.bLightShaftUse;
|
|
bool bUseDof = !bUseEncodedHDR && GetMobileDepthOfFieldScale(View) > 0.0f && !Context.View.Family->EngineShowFlags.VisualizeDOF;
|
|
bool bUseBloom = View.FinalPostProcessSettings.BloomIntensity > 0.0f;
|
|
bool bUseVignette = View.FinalPostProcessSettings.VignetteIntensity > 0.0f;
|
|
|
|
bool bWorkaround = CVarRenderTargetSwitchWorkaround.GetValueOnRenderThread() != 0;
|
|
|
|
// Use original mobile Dof on ES2 devices regardless of bMobileHQGaussian.
|
|
// HQ gaussian
|
|
bool bUseMobileDof = bUseDof && (!View.FinalPostProcessSettings.bMobileHQGaussian || (Context.View.GetFeatureLevel() < ERHIFeatureLevel::ES3_1));
|
|
|
|
// This is a workaround to avoid a performance cliff when using many render targets.
|
|
bool bUseBloomSmall = bUseBloom && !bUseSun && !bUseDof && bWorkaround;
|
|
|
|
bool bUsePost = bUseSun | bUseDof | bUseBloom | bUseVignette;
|
|
|
|
// Post is not supported on ES2 devices using mosaic.
|
|
bUsePost &= !bUseMosaic;
|
|
bUsePost &= IsMobileHDR();
|
|
|
|
if(bUsePost)
|
|
{
|
|
// Skip this pass if the pass was done prior before resolve.
|
|
if ((!bUsedFramebufferFetch) && (bUseSun || bUseDof))
|
|
{
|
|
// Convert depth to {circle of confusion, sun shaft intensity} before resolve.
|
|
// FRenderingCompositePass* PostProcessSunMask = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSunMaskES2(PrePostSourceViewportSize, false));
|
|
FRenderingCompositePass* PostProcessSunMask = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSunMaskES2(SceneColorSize, false));
|
|
PostProcessSunMask->SetInput(ePId_Input0, Context.FinalOutput);
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(PostProcessSunMask);
|
|
//@todo Ronin sunmask pass isnt clipping to image only.
|
|
}
|
|
|
|
FRenderingCompositeOutputRef PostProcessBloomSetup;
|
|
if (bUseSun || bUseMobileDof || bUseBloom)
|
|
{
|
|
if(bUseBloomSmall)
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomSetupSmallES2(PrePostSourceViewportSize, bViewRectSource));
|
|
Pass->SetInput(ePId_Input0, Context.FinalOutput);
|
|
PostProcessBloomSetup = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
else
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomSetupES2(FinalOutputViewRect, bViewRectSource));
|
|
Pass->SetInput(ePId_Input0, Context.FinalOutput);
|
|
PostProcessBloomSetup = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
}
|
|
|
|
if (bUseDof)
|
|
{
|
|
if (bUseMobileDof)
|
|
{
|
|
// Near dilation circle of confusion size.
|
|
// Samples at 1/16 area, writes to 1/16 area.
|
|
FRenderingCompositeOutputRef PostProcessNear;
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDofNearES2(FinalOutputViewRect.Size()));
|
|
Pass->SetInput(ePId_Input0, PostProcessBloomSetup);
|
|
PostProcessNear = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// DOF downsample pass.
|
|
// Samples at full resolution, writes to 1/4 area.
|
|
FRenderingCompositeOutputRef PostProcessDofDown;
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDofDownES2(FinalOutputViewRect, bViewRectSource));
|
|
Pass->SetInput(ePId_Input0, Context.FinalOutput);
|
|
Pass->SetInput(ePId_Input1, PostProcessNear);
|
|
PostProcessDofDown = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// DOF blur pass.
|
|
// Samples at 1/4 area, writes to 1/4 area.
|
|
FRenderingCompositeOutputRef PostProcessDofBlur;
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessDofBlurES2(FinalOutputViewRect.Size()));
|
|
Pass->SetInput(ePId_Input0, PostProcessDofDown);
|
|
Pass->SetInput(ePId_Input1, PostProcessNear);
|
|
PostProcessDofBlur = FRenderingCompositeOutputRef(Pass);
|
|
DofOutput = PostProcessDofBlur;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// black is how we clear the velocity buffer so this means no velocity
|
|
FRenderingCompositePass* NoVelocity = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(GSystemTextures.BlackDummy));
|
|
FRenderingCompositeOutputRef NoVelocityRef(NoVelocity);
|
|
if(View.FinalPostProcessSettings.DepthOfFieldMethod == DOFM_Gaussian && IsGaussianActive(Context))
|
|
{
|
|
FDepthOfFieldStats DepthOfFieldStat;
|
|
FRenderingCompositeOutputRef DummySeparateTranslucency;
|
|
AddPostProcessDepthOfFieldGaussian(Context, DepthOfFieldStat, NoVelocityRef, DummySeparateTranslucency);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Bloom.
|
|
FRenderingCompositeOutputRef PostProcessDownsample2;
|
|
FRenderingCompositeOutputRef PostProcessDownsample3;
|
|
FRenderingCompositeOutputRef PostProcessDownsample4;
|
|
FRenderingCompositeOutputRef PostProcessDownsample5;
|
|
FRenderingCompositeOutputRef PostProcessUpsample4;
|
|
FRenderingCompositeOutputRef PostProcessUpsample3;
|
|
FRenderingCompositeOutputRef PostProcessUpsample2;
|
|
|
|
if(bUseBloomSmall)
|
|
{
|
|
float DownScale = 0.66f * 4.0f;
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/4, DownScale * 2.0f));
|
|
Pass->SetInput(ePId_Input0, PostProcessBloomSetup);
|
|
PostProcessDownsample2 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
}
|
|
|
|
if(bUseBloom && (!bUseBloomSmall))
|
|
{
|
|
float DownScale = 0.66f * 4.0f;
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/4, DownScale));
|
|
Pass->SetInput(ePId_Input0, PostProcessBloomSetup);
|
|
PostProcessDownsample2 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/8, DownScale));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample2);
|
|
PostProcessDownsample3 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/16, DownScale));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample3);
|
|
PostProcessDownsample4 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Downsample by 2
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomDownES2(PrePostSourceViewportSize/32, DownScale));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample4);
|
|
PostProcessDownsample5 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
const FFinalPostProcessSettings& Settings = Context.View.FinalPostProcessSettings;
|
|
|
|
float UpScale = 0.66f * 2.0f;
|
|
// Upsample by 2
|
|
{
|
|
FVector4 TintA = FVector4(Settings.Bloom4Tint.R, Settings.Bloom4Tint.G, Settings.Bloom4Tint.B, 0.0f);
|
|
FVector4 TintB = FVector4(Settings.Bloom5Tint.R, Settings.Bloom5Tint.G, Settings.Bloom5Tint.B, 0.0f);
|
|
TintA *= View.FinalPostProcessSettings.BloomIntensity;
|
|
TintB *= View.FinalPostProcessSettings.BloomIntensity;
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomUpES2(PrePostSourceViewportSize/32, FVector2D(UpScale, UpScale), TintA, TintB));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample4);
|
|
Pass->SetInput(ePId_Input1, PostProcessDownsample5);
|
|
PostProcessUpsample4 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Upsample by 2
|
|
{
|
|
FVector4 TintA = FVector4(Settings.Bloom3Tint.R, Settings.Bloom3Tint.G, Settings.Bloom3Tint.B, 0.0f);
|
|
TintA *= View.FinalPostProcessSettings.BloomIntensity;
|
|
FVector4 TintB = FVector4(1.0f, 1.0f, 1.0f, 0.0f);
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomUpES2(PrePostSourceViewportSize/16, FVector2D(UpScale, UpScale), TintA, TintB));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample3);
|
|
Pass->SetInput(ePId_Input1, PostProcessUpsample4);
|
|
PostProcessUpsample3 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Upsample by 2
|
|
{
|
|
FVector4 TintA = FVector4(Settings.Bloom2Tint.R, Settings.Bloom2Tint.G, Settings.Bloom2Tint.B, 0.0f);
|
|
TintA *= View.FinalPostProcessSettings.BloomIntensity;
|
|
// Scaling Bloom2 by extra factor to match filter area difference between PC default and mobile.
|
|
TintA *= 0.5;
|
|
FVector4 TintB = FVector4(1.0f, 1.0f, 1.0f, 0.0f);
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessBloomUpES2(PrePostSourceViewportSize/8, FVector2D(UpScale, UpScale), TintA, TintB));
|
|
Pass->SetInput(ePId_Input0, PostProcessDownsample2);
|
|
Pass->SetInput(ePId_Input1, PostProcessUpsample3);
|
|
PostProcessUpsample2 = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
}
|
|
|
|
FRenderingCompositeOutputRef PostProcessSunBlur;
|
|
if(bUseSun)
|
|
{
|
|
// Sunshaft depth blur using downsampled alpha.
|
|
FRenderingCompositeOutputRef PostProcessSunAlpha;
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSunAlphaES2(PrePostSourceViewportSize));
|
|
Pass->SetInput(ePId_Input0, PostProcessBloomSetup);
|
|
PostProcessSunAlpha = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
|
|
// Sunshaft blur number two.
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSunBlurES2(PrePostSourceViewportSize));
|
|
Pass->SetInput(ePId_Input0, PostProcessSunAlpha);
|
|
PostProcessSunBlur = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
}
|
|
|
|
if(bUseSun | bUseVignette | bUseBloom)
|
|
{
|
|
FRenderingCompositeOutputRef PostProcessSunMerge;
|
|
if(bUseBloomSmall)
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSunMergeSmallES2(PrePostSourceViewportSize));
|
|
Pass->SetInput(ePId_Input0, PostProcessBloomSetup);
|
|
Pass->SetInput(ePId_Input1, PostProcessDownsample2);
|
|
PostProcessSunMerge = FRenderingCompositeOutputRef(Pass);
|
|
BloomOutput = PostProcessSunMerge;
|
|
}
|
|
else
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSunMergeES2(PrePostSourceViewportSize));
|
|
if(bUseSun)
|
|
{
|
|
Pass->SetInput(ePId_Input0, PostProcessSunBlur);
|
|
}
|
|
if(bUseBloom)
|
|
{
|
|
Pass->SetInput(ePId_Input1, PostProcessBloomSetup);
|
|
Pass->SetInput(ePId_Input2, PostProcessUpsample2);
|
|
}
|
|
PostProcessSunMerge = FRenderingCompositeOutputRef(Pass);
|
|
BloomOutput = PostProcessSunMerge;
|
|
}
|
|
|
|
// Mobile temporal AA requires a composite of two of these frames.
|
|
if(bUseAa && (bUseBloom || bUseSun))
|
|
{
|
|
FSceneViewState* ViewState = (FSceneViewState*)View.State;
|
|
FRenderingCompositeOutputRef PostProcessSunMerge2;
|
|
if(ViewState && ViewState->MobileAaBloomSunVignette1)
|
|
{
|
|
FRenderingCompositePass* History;
|
|
History = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(ViewState->MobileAaBloomSunVignette1));
|
|
PostProcessSunMerge2 = FRenderingCompositeOutputRef(History);
|
|
}
|
|
else
|
|
{
|
|
PostProcessSunMerge2 = PostProcessSunMerge;
|
|
}
|
|
|
|
FRenderingCompositeOutputRef PostProcessSunAvg;
|
|
{
|
|
FRenderingCompositePass* Pass = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessSunAvgES2(PrePostSourceViewportSize));
|
|
Pass->SetInput(ePId_Input0, PostProcessSunMerge);
|
|
Pass->SetInput(ePId_Input1, PostProcessSunMerge2);
|
|
PostProcessSunAvg = FRenderingCompositeOutputRef(Pass);
|
|
}
|
|
BloomOutput = PostProcessSunAvg;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!bUseMosaic && IsMobileHDR())
|
|
{
|
|
AddPostProcessMaterial(Context, BL_BeforeTranslucency, nullptr);
|
|
AddPostProcessMaterial(Context, BL_BeforeTonemapping, nullptr);
|
|
}
|
|
}
|
|
|
|
static const auto VarTonemapperFilm = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.TonemapperFilm"));
|
|
const bool bUseTonemapperFilm = IsMobileHDR() && GSupportsRenderTargetFormat_PF_FloatRGBA && (VarTonemapperFilm && VarTonemapperFilm->GetValueOnRenderThread());
|
|
if (bUseTonemapperFilm)
|
|
{
|
|
//@todo Ronin Set to EAutoExposureMethod::AEM_Basic for PC vk crash.
|
|
AddTonemapper(Context, BloomOutput, nullptr, EAutoExposureMethod::AEM_Histogram, false, false);
|
|
}
|
|
else
|
|
{
|
|
// Must run to blit to back buffer even if post processing is off.
|
|
FRenderingCompositePass* PostProcessTonemap = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessTonemapES2(Context.View, FinalOutputViewRect, FinalTargetSize, bViewRectSource));
|
|
PostProcessTonemap->SetInput(ePId_Input0, Context.FinalOutput);
|
|
PostProcessTonemap->SetInput(ePId_Input1, BloomOutput);
|
|
PostProcessTonemap->SetInput(ePId_Input2, DofOutput);
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(PostProcessTonemap);
|
|
}
|
|
|
|
// if Context.FinalOutput was the clipped result of sunmask stage then this stage also restores Context.FinalOutput back original target size.
|
|
FinalOutputViewRect = View.UnscaledViewRect;
|
|
|
|
if (View.Family->EngineShowFlags.PostProcessing)
|
|
{
|
|
if (bUseAa)
|
|
{
|
|
// Double buffer post output.
|
|
FSceneViewState* ViewState = (FSceneViewState*)View.State;
|
|
|
|
FRenderingCompositeOutputRef PostProcessPrior = Context.FinalOutput;
|
|
if(ViewState && ViewState->MobileAaColor1)
|
|
{
|
|
FRenderingCompositePass* History;
|
|
History = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(ViewState->MobileAaColor1));
|
|
PostProcessPrior = FRenderingCompositeOutputRef(History);
|
|
}
|
|
|
|
// Mobile temporal AA is done after tonemapping.
|
|
FRenderingCompositePass* PostProcessAa = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessAaES2());
|
|
PostProcessAa->SetInput(ePId_Input0, Context.FinalOutput);
|
|
PostProcessAa->SetInput(ePId_Input1, PostProcessPrior);
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(PostProcessAa);
|
|
}
|
|
|
|
if (IsMobileHDR() && !IsMobileHDRMosaic())
|
|
{
|
|
AddPostProcessMaterial(Context, BL_AfterTonemapping, nullptr);
|
|
}
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
if (FSceneRenderer::ShouldCompositeEditorPrimitives(View) )
|
|
{
|
|
FRenderingCompositePass* EditorCompNode = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessCompositeEditorPrimitives(false));
|
|
EditorCompNode->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(EditorCompNode);
|
|
}
|
|
#endif
|
|
|
|
const EDebugViewShaderMode DebugViewShaderMode = View.Family->GetDebugViewShaderMode();
|
|
if(DebugViewShaderMode == DVSM_QuadComplexity)
|
|
{
|
|
// Legend is costly so we don't do it for ES2, ideally we make a shader permutation
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeComplexity(GEngine->QuadComplexityColors, FVisualizeComplexityApplyPS::CS_STAIR, 1.f, false));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
if(DebugViewShaderMode == DVSM_ShaderComplexity || DebugViewShaderMode == DVSM_ShaderComplexityContainedQuadOverhead || DebugViewShaderMode == DVSM_ShaderComplexityBleedingQuadOverhead)
|
|
{
|
|
// Legend is costly so we don't do it for ES2, ideally we make a shader permutation
|
|
FRenderingCompositePass* Node = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessVisualizeComplexity(GEngine->ShaderComplexityColors, FVisualizeComplexityApplyPS::CS_RAMP, 1.f, false));
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
|
|
bool bStereoRenderingAndHMD = View.Family->EngineShowFlags.StereoRendering && View.Family->EngineShowFlags.HMDDistortion;
|
|
if (bStereoRenderingAndHMD)
|
|
{
|
|
FRenderingCompositePass* Node = NULL;
|
|
const EHMDDeviceType::Type DeviceType = GEngine->HMDDevice->GetHMDDeviceType();
|
|
if (DeviceType == EHMDDeviceType::DT_ES2GenericStereoMesh)
|
|
{
|
|
Node = Context.Graph.RegisterPass(new FRCPassPostProcessHMD());
|
|
}
|
|
|
|
if (Node)
|
|
{
|
|
Node->SetInput(ePId_Input0, FRenderingCompositeOutputRef(Context.FinalOutput));
|
|
Context.FinalOutput = FRenderingCompositeOutputRef(Node);
|
|
}
|
|
}
|
|
|
|
// The graph setup should be finished before this line ----------------------------------------
|
|
|
|
{
|
|
// currently created on the heap each frame but View.Family->RenderTarget could keep this object and all would be cleaner
|
|
TRefCountPtr<IPooledRenderTarget> Temp;
|
|
FSceneRenderTargetItem Item;
|
|
Item.TargetableTexture = (FTextureRHIRef&)View.Family->RenderTarget->GetRenderTargetTexture();
|
|
Item.ShaderResourceTexture = (FTextureRHIRef&)View.Family->RenderTarget->GetRenderTargetTexture();
|
|
|
|
FPooledRenderTargetDesc Desc;
|
|
|
|
if (View.Family->RenderTarget->GetRenderTargetTexture())
|
|
{
|
|
Desc.Extent.X = View.Family->RenderTarget->GetRenderTargetTexture()->GetSizeX();
|
|
Desc.Extent.Y = View.Family->RenderTarget->GetRenderTargetTexture()->GetSizeY();
|
|
}
|
|
else
|
|
{
|
|
Desc.Extent = View.Family->RenderTarget->GetSizeXY();
|
|
}
|
|
|
|
// todo: this should come from View.Family->RenderTarget
|
|
Desc.Format = PF_B8G8R8A8;
|
|
Desc.NumMips = 1;
|
|
|
|
GRenderTargetPool.CreateUntrackedElement(Desc, Temp, Item);
|
|
|
|
OverrideRenderTarget(Context.FinalOutput, Temp, Desc);
|
|
|
|
CompositeContext.Process(Context.FinalOutput.GetPass(), TEXT("PostProcessingES2"));
|
|
}
|
|
}
|
|
}
|
|
|
|
void FPostProcessing::ProcessPlanarReflection(FRHICommandListImmediate& RHICmdList, FViewInfo& View, TRefCountPtr<IPooledRenderTarget>& VelocityRT, TRefCountPtr<IPooledRenderTarget>& OutFilteredSceneColor)
|
|
{
|
|
{
|
|
FMemMark Mark(FMemStack::Get());
|
|
FRenderingCompositePassContext CompositeContext(RHICmdList, View);
|
|
|
|
FPostprocessContext Context(RHICmdList, CompositeContext.Graph, View);
|
|
FSceneRenderTargets& SceneContext = FSceneRenderTargets::Get(RHICmdList);
|
|
|
|
FRenderingCompositeOutputRef VelocityInput;
|
|
if(VelocityRT)
|
|
{
|
|
VelocityInput = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(VelocityRT));
|
|
}
|
|
|
|
FSceneViewState* ViewState = Context.View.ViewState;
|
|
EAntiAliasingMethod AntiAliasingMethod = Context.View.AntiAliasingMethod;
|
|
|
|
if (AntiAliasingMethod == AAM_TemporalAA && ViewState)
|
|
{
|
|
if(VelocityInput.IsValid())
|
|
{
|
|
AddTemporalAA( Context, VelocityInput );
|
|
}
|
|
else
|
|
{
|
|
// black is how we clear the velocity buffer so this means no velocity
|
|
FRenderingCompositePass* NoVelocity = Context.Graph.RegisterPass(new(FMemStack::Get()) FRCPassPostProcessInput(GSystemTextures.BlackDummy));
|
|
FRenderingCompositeOutputRef NoVelocityRef(NoVelocity);
|
|
AddTemporalAA( Context, NoVelocityRef );
|
|
}
|
|
}
|
|
|
|
CompositeContext.Process(Context.FinalOutput.GetPass(), TEXT("ProcessPlanarReflection"));
|
|
|
|
OutFilteredSceneColor = Context.FinalOutput.GetOutput()->PooledRenderTarget;
|
|
}
|
|
}
|