Engine/Shaders/Private/Lumen/LumenCardVertexShader.usf
// Copyright Epic Games, Inc. All Rights Reserved.
#include "../Common.ush"
// Reroute SceneTexturesStruct uniform buffer references to the appropriate pass uniform buffer
#define SceneTexturesStruct LumenCardPass.SceneTextures
#include "/Engine/Generated/Material.ush"
#include "/Engine/Generated/VertexFactory.ush"
struct FLumenCardInterpolantsVSToPS
{
};
struct FLumenCardVSToPS
{
FVertexFactoryInterpolantsVSToPS FactoryInterpolants;
FLumenCardInterpolantsVSToPS PassInterpolants;
float4 Position : SV_POSITION;
};
void Main(
FVertexFactoryInput Input,
out FLumenCardVSToPS Output
)
{
uint EyeIndex = 0;
ResolvedView = ResolveView();
FVertexFactoryIntermediates VFIntermediates = GetVertexFactoryIntermediates(Input);
float4 WorldPositionExcludingWPO = VertexFactoryGetWorldPosition(Input, VFIntermediates);
float4 WorldPosition = WorldPositionExcludingWPO;
float4 ClipSpacePosition;
float3x3 TangentToLocal = VertexFactoryGetTangentToLocal(Input, VFIntermediates);
FMaterialVertexParameters VertexParameters = GetMaterialVertexParameters(Input, VFIntermediates, WorldPosition.xyz, TangentToLocal);
ISOLATE
{
// Don't use WPO as Lumen cards and mesh SDF are computed without them
//WorldPosition.xyz += GetMaterialWorldPositionOffset(VertexParameters);
float4 RasterizedWorldPosition = VertexFactoryGetRasterizedWorldPosition(Input, VFIntermediates, WorldPosition);
ClipSpacePosition = mul(RasterizedWorldPosition, ResolvedView.TranslatedWorldToClip);
Output.Position = ClipSpacePosition;
}
Output.FactoryInterpolants = VertexFactoryGetInterpolantsVSToPS(Input, VFIntermediates, VertexParameters);
}
Engine/Shaders/Private/Lumen/LumenCardPixelShader.usf
struct FLumenCardInterpolantsVSToPS
{
};
void Main(
FVertexFactoryInterpolantsVSToPS Interpolants,
FLumenCardInterpolantsVSToPS PassInterpolants,
in float4 SvPosition : SV_Position
, in bool bIsFrontFace : SV_IsFrontFace ,
out float4 OutTarget0 : SV_Target0,
out float4 OutTarget1 : SV_Target1,
out float4 OutTarget2 : SV_Target2)
{
ResolvedView = ResolveView();
FMaterialPixelParameters MaterialParameters;
{
MaterialParameters = GetMaterialPixelParameters(Interpolants, SvPosition);
}
FPixelMaterialInputs PixelMaterialInputs;
{
float4 ScreenPosition = SvPositionToResolvedScreenPosition(SvPosition);
float3 TranslatedWorldPosition = SvPositionToResolvedTranslatedWorld(SvPosition);
CalcMaterialParametersEx(MaterialParameters, PixelMaterialInputs, SvPosition, ScreenPosition, bIsFrontFace, TranslatedWorldPosition, TranslatedWorldPosition);
}
float3 BaseColor = GetMaterialBaseColor(PixelMaterialInputs);
float Metallic = GetMaterialMetallic(PixelMaterialInputs);
float Specular = GetMaterialSpecular(PixelMaterialInputs);
float Roughness = GetMaterialRoughness(PixelMaterialInputs);
float3 Emissive = GetMaterialEmissive(PixelMaterialInputs);
float3 WorldNormal = MaterialParameters.WorldNormal;
float Opacity = 1.0f;
float3 DiffuseColor = BaseColor - BaseColor * Metallic;
float3 SpecularColor = lerp(0.08f * Specular.xxx, BaseColor, Metallic.xxx);
EnvBRDFApproxFullyRough(DiffuseColor, SpecularColor);
uint ShadingModel = GetMaterialShadingModel(PixelMaterialInputs);
float3 SubsurfaceColor = 0.0f;
float3 CardSpaceNormal = float3(0, 0, 1);
if (all(IsFinite(WorldNormal)))
{
WorldNormal = normalize(WorldNormal);
CardSpaceNormal = mul(float4(WorldNormal, 0.0f), ResolvedView.TranslatedWorldToView).xyz;
}
OutTarget0 = float4(sqrt(DiffuseColor), Opacity);
OutTarget1 = float4(CardSpaceNormal.xy * 0.5f + 0.5f, 0.0f, 1.0f);
OutTarget2 = float4(Emissive, 0.0f);
}