Files
UnrealEngineUWP/Engine/Shaders/PostProcessMaterialShaders.usf
Joe Tidmarsh c489d646df #ttp 316639 - UE4: RENDERING: DrawDenormalizedQuad should reuse static index and vertexbuffer
#summary UV offsets are now correctly calculated. This was previously blocking shadow game

[CL 2039548 by Joe Tidmarsh in Main branch]
2014-04-23 17:26:59 -04:00

49 lines
1.5 KiB
Plaintext

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
PostProcessMaterialShaders.usf: Shaders for rendering post process materials
=============================================================================*/
#include "Common.usf"
#include "Material.usf"
void MainVS(
in float4 InPosition : ATTRIBUTE0,
out float4 OutScreenPosition : TEXCOORD0,
out float4 OutPosition : SV_POSITION
)
{
DrawRectangle(InPosition, OutPosition);
OutScreenPosition = OutPosition;
}
void MainPS(
in float4 ScreenPosition : TEXCOORD0,
out float4 OutColor : SV_Target0
)
{
FMaterialPixelParameters Parameters = MakeInitializedMaterialPixelParameters();
float2 ScreenUV = ScreenAlignedPosition(ScreenPosition);
#if NUM_MATERIAL_TEXCOORDS
for(int CoordinateIndex = 0;CoordinateIndex < NUM_MATERIAL_TEXCOORDS;CoordinateIndex++)
{
Parameters.TexCoords[CoordinateIndex] = ScreenUV;
}
#endif
Parameters.VertexColor = 1;
// Deproject quad pixel position into world
float SceneDepth = CalcSceneDepth(ScreenUV);
float3 ScreenVector = mul(float4(ScreenPosition.xy, 1, 0), View.ScreenToWorld).xyz;
float3 WorldPosition = ScreenVector * SceneDepth;
// fill out other related material parameters
CalcMaterialParameters(Parameters, true, float4(WorldPosition, 1));
Parameters.ScreenPosition = ScreenPosition;
// Grab emissive colour as output
OutColor = float4(GetMaterialEmissive(Parameters), 1);
}