2022-09-21 15:02:39 +00:00
|
|
|
// Copyright 2022 Manuel Wagner - All rights reserved
|
|
|
|
|
|
|
|
Texture2D InputTexture;
|
|
|
|
SamplerState InputTextureSampler;
|
|
|
|
RWBuffer<float> OutputUAV;
|
|
|
|
uint2 OutputDimensions; // X = InputTensor.GetSize(1), Y = InputTensor.GetSize(2) -> this does not correspond to input texture XY
|
|
|
|
float2 HalfPixelUV;
|
|
|
|
|
|
|
|
[numthreads(THREADGROUP_SIZE_X, THREADGROUP_SIZE_Y, THREADGROUP_SIZE_Z)]
|
|
|
|
void ShadowMaskToInputTensorCS(in const uint3 DispatchThreadID : SV_DispatchThreadID)
|
|
|
|
{
|
|
|
|
const uint2 OutputUAVTexelCoordinate = DispatchThreadID.xy;
|
|
|
|
if(any(OutputUAVTexelCoordinate >= OutputDimensions))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-13 13:32:30 +00:00
|
|
|
const uint GlobalIndex = OutputUAVTexelCoordinate.x * OutputDimensions.y + OutputUAVTexelCoordinate.y;
|
2022-09-21 15:02:39 +00:00
|
|
|
|
|
|
|
// note that the OutputUAV has shape (1, Y, X, C)
|
|
|
|
// which is why we need to flip the indexing
|
|
|
|
const float2 UV = float2(OutputUAVTexelCoordinate.yx) / float2(OutputDimensions.yx) + HalfPixelUV;
|
|
|
|
|
|
|
|
const float4 TextureValue = InputTexture.SampleLevel(InputTextureSampler, UV, 0);
|
|
|
|
|
|
|
|
OutputUAV[GlobalIndex + 0] = TextureValue.r;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "/Engine/Public/Platform.ush"
|