Files
UnrealEngineUWP/Engine/Shaders/ResolvePixelShader.usf
Graeme Thornton 9576f1f08d Create and use auxilliary depth texture in the forward rendering path when simulationous depth test/read isn't supported on the target hardware.
Fixes TTP 335869 - UE4: RENDERING: CRITICAL: EDITOR: CRASH: Occurs when launching mobile preview on the StarterMap using the Asus UX31 Sandy Bridge Ultrabook

[CL 2119491 by Graeme Thornton in Main branch]
2014-06-27 10:57:41 -04:00

66 lines
1.5 KiB
Plaintext

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
ResolvePixelShader.usf: Resolve pixel shader source.
=============================================================================*/
#include "Common.usf"
#if FEATURE_LEVEL >= FEATURE_LEVEL_SM5
Texture2DMS<float4> UnresolvedSurface;
void MainDepth(
float2 InUV : TEXCOORD0,
out float OutDepth : SV_DEPTH
)
{
float2 SurfaceDimensions;
int NumSurfaceSamples;
UnresolvedSurface.GetDimensions(SurfaceDimensions.x,SurfaceDimensions.y,NumSurfaceSamples);
int2 IntUV = trunc(InUV);
// Compute the minimum depth of all samples.
// Note that minimum depth actually means farthest depth, since 1/depth is stored.
float MinDepth = 1000000;
for(int SampleIndex = 0;SampleIndex < NumSurfaceSamples;++SampleIndex)
{
float Sample = UnresolvedSurface.Load(IntUV,SampleIndex).r;
MinDepth = min(MinDepth,Sample);
}
OutDepth = MinDepth;
}
uint SingleSampleIndex;
void MainSingleSample(
float2 InUV : TEXCOORD0,
out float4 OutColor : SV_Target0
)
{
float2 SurfaceDimensions;
int NumSurfaceSamples;
UnresolvedSurface.GetDimensions(SurfaceDimensions.x,SurfaceDimensions.y,NumSurfaceSamples);
int2 IntUV = trunc(InUV);
OutColor = UnresolvedSurface.Load(IntUV,SingleSampleIndex);
}
#else
Texture2D UnresolvedSurfaceNonMS;
void MainDepthNonMS(
float2 InUV : TEXCOORD0,
out float OutDepth : SV_DEPTH
)
{
int3 IntUV = int3(trunc(InUV),0);
float Sample = UnresolvedSurfaceNonMS.Load(IntUV).r;
OutDepth = Sample;
}
#endif