Files
UnrealEngineUWP/Engine/Shaders/MobileSceneCapture.usf
Ben Marsh 20bf0eb6a1 Updating copyright notices to 2017 (copying from //Tasks/UE4/Dev-Copyright-2017).
#rb none
#lockdown Nick.Penwarden

[CL 3226823 by Ben Marsh in Main branch]
2016-12-08 08:52:44 -05:00

64 lines
1.8 KiB
Plaintext

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
Decode32bppHDR.usf: Decode 32bpp HDR encoding
=============================================================================*/
#include "Common.usf"
float2 InvTexSize;
void MainCopyVS(
float2 InPosition : ATTRIBUTE0,
float2 InUV : ATTRIBUTE1,
#if DECODING_MOSAIC
out float2 OutTexCoords[4] : TEXCOORD4,
#endif
out FScreenVertexOutput Output
)
{
DrawRectangle( float4( InPosition, 0, 1 ), InUV, Output.Position, Output.UV);
#if DECODING_MOSAIC
OutTexCoords[0] = Output.UV + InvTexSize.xy * float2( 0,-1);
OutTexCoords[1] = Output.UV + InvTexSize.xy * float2( 1, 0);
OutTexCoords[2] = Output.UV + InvTexSize.xy * float2(-1, 0);
OutTexCoords[3] = Output.UV + InvTexSize.xy * float2( 0, 1);
#endif
}
Texture2D InTexture;
SamplerState InTextureSampler;
void MainCopyPS(
#if DECODING_MOSAIC
in float2 InTexCoords[4] : TEXCOORD4,
#endif
FScreenVertexOutput Input,
out float4 OutColor : SV_Target0
)
{
float4 EncodedColor = Texture2DSample(InTexture, InTextureSampler, Input.UV);
// Decode EncodedColor, OutColor will saturate on 8 bit RTs.
#if DECODING_MOSAIC
OutColor = Decode32BPPHDR(EncodedColor, Input.Position, InTexture, InTextureSampler, InTexCoords);
#else
OutColor = Decode32BPPHDR(EncodedColor);
#endif
float SceneW = CalcSceneDepth(Input.UV);
#if SOURCE_MODE_SCENE_COLOR_AND_OPACITY
// Put inverse opacity in alpha channel. (determined via depth, translucency is combined with another pass.)
float MaxSceneDepth = 65000.0f;
OutColor.a = SceneW >= MaxSceneDepth ? 1.0f : 0.0f;
#elif SOURCE_MODE_SCENE_COLOR_NO_ALPHA
OutColor.a = 0;
#elif SOURCE_MODE_SCENE_COLOR_SCENE_DEPTH
OutColor.a = SceneW;
#elif SOURCE_MODE_SCENE_DEPTH
OutColor.r = float4(SceneW,0,0,0);
#endif
}