You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Common.ush"
|
|
#include "ScreenPass.ush"
|
|
#include "DepthOfFieldCommon.ush"
|
|
|
|
Texture2D ColorTexture;
|
|
SamplerState ColorSampler;
|
|
|
|
Texture2D DepthTexture;
|
|
SamplerState DepthSampler;
|
|
|
|
float4 NearColor;
|
|
float4 FarColor;
|
|
|
|
// render in fullres to visualize the half res DOF input from the setup pass
|
|
void VisualizeDOFPS(
|
|
in noperspective float4 UVAndScreenPos : TEXCOORD0,
|
|
float4 SvPosition : SV_POSITION,
|
|
out float4 OutColor : SV_Target0)
|
|
{
|
|
OutColor = 0;
|
|
|
|
float2 UV = UVAndScreenPos.xy;
|
|
int2 PixelPos = (int2)SvPosition.xy;
|
|
float2 ViewLocalUV = float2(UVAndScreenPos.z * 0.5f + 0.5f, 0.5f - 0.5f * UVAndScreenPos.w);
|
|
|
|
float SceneDeviceZ = DepthTexture.SampleLevel(DepthSampler, UV, 0).r;
|
|
float SceneDepth = ConvertFromDeviceZ(SceneDeviceZ);
|
|
|
|
// 0..1
|
|
half Near = CalcUnfocusedPercentCustomBound(SceneDepth, 1, 0);
|
|
// 0..1
|
|
half Far = CalcUnfocusedPercentCustomBound(SceneDepth, 0, 1);
|
|
|
|
OutColor.rgb = lerp(OutColor.rgb, NearColor.rgb, Near);
|
|
OutColor.rgb = lerp(OutColor.rgb, FarColor.rgb, Far);
|
|
|
|
half3 SceneColor = Texture2DSample(ColorTexture, ColorSampler, UV).rgb;
|
|
|
|
// blend in a bit of the scene color to make navigation easier
|
|
OutColor.rgb = lerp(saturate(OutColor.rgb), Luminance(SceneColor), 0.1f);
|
|
} |