2014-03-14 14:13:41 -04:00
|
|
|
// 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
|
|
|
|
|
)
|
|
|
|
|
{
|
2014-04-23 17:26:59 -04:00
|
|
|
DrawRectangle(InPosition, OutPosition);
|
|
|
|
|
OutScreenPosition = OutPosition;
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|