Files
UnrealEngineUWP/Engine/Shaders/Private/HeightFieldAtlasManagement.usf
jian ru 97a524b0cd RTHF shadow - added support that allows light cast inside terrains through holes. Due to its cost, it is only enabled in the highest quality level. Currently, boundaries are jaggy for shadows cast through holes. Users need to hide the aritifact with DF shadow by placing static meshes around holes.
Fixed a crash that can happen on exit.
Further reduced self shadow artifact when using RTHF shadow.


#ROBOMERGE-SOURCE: CL 11077247 via CL 11077248 via CL 11077250
#ROBOMERGE-BOT: (v637-11041722)

[CL 11077251 by jian ru in Main branch]
2020-01-21 16:48:23 -05:00

44 lines
1.5 KiB
Plaintext

// Copyright Epic Games, Inc. All Rights Reserved.
/*=============================================================================
HeightFieldAtlasManagement.usf
=============================================================================*/
#include "Common.ush"
uint4 UpdateRegionOffsetAndSize;
float4 SourceScaleBias;
uint SourceMipBias;
Texture2D<float4> SourceTexture;
SamplerState SourceTextureSampler;
RWTexture2D<float2> RWHeightFieldAtlas;
[numthreads(THREADGROUP_SIZEX, THREADGROUP_SIZEY, 1)]
void UploadHeightFieldToAtlasCS(uint3 DispatchThreadId : SV_DispatchThreadID)
{
if (all(DispatchThreadId.xy < UpdateRegionOffsetAndSize.zw))
{
float2 SourceUV = DispatchThreadId.xy * SourceScaleBias.xy + SourceScaleBias.zw;
uint2 WriteCoord = DispatchThreadId.xy + UpdateRegionOffsetAndSize.xy;
RWHeightFieldAtlas[WriteCoord] = Texture2DSampleLevel(SourceTexture, SourceTextureSampler, SourceUV, SourceMipBias).xy;
}
}
float4 VisibilityChannelMask;
RWTexture2D<float> RWVisibilityAtlas;
[numthreads(THREADGROUP_SIZEX, THREADGROUP_SIZEY, 1)]
void UploadVisibilityToAtlasCS(uint3 DispatchThreadId : SV_DispatchThreadID)
{
if (all(DispatchThreadId.xy < UpdateRegionOffsetAndSize.zw))
{
float2 SourceUV = DispatchThreadId.xy * SourceScaleBias.xy + SourceScaleBias.zw;
uint2 WriteCoord = DispatchThreadId.xy + UpdateRegionOffsetAndSize.xy;
RWVisibilityAtlas[WriteCoord] = dot(Texture2DSampleLevel(SourceTexture, SourceTextureSampler, SourceUV, SourceMipBias), VisibilityChannelMask);
}
}