You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This CL changes Strata_For macro to ensure that BSDFs are not processed if there are invalid. It also temporarly disable cluster shading on FXC as the compiler has issue with the current code layout. #rb none #jira none #fyi sebastien.hillaire #preflight shaders [CL 20437092 by Charles deRousiers in ue5-main branch]
118 lines
3.9 KiB
Plaintext
118 lines
3.9 KiB
Plaintext
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
// Sanity guard.
|
|
#ifndef STRATA_ENABLED
|
|
#define STRATA_ENABLED 1
|
|
#error STRATA_ENABLED needs to be defined
|
|
#endif
|
|
|
|
#if STRATA_ENABLED
|
|
|
|
#define USE_STRATA_ENV_LIGHTING_COMMON 1
|
|
#include "StrataLightingCommon.ush"
|
|
|
|
// Env. lighting evaluation for strata material.
|
|
// Unpack BSDF on-the-fly
|
|
FStrataDeferredLighting StrataEnvironmentLighting(
|
|
float4 SvPosition,
|
|
float2 BufferUV,
|
|
float SceneDepth,
|
|
float3 WorldPosition,
|
|
float3 TranslatedWorldPosition,
|
|
float3 CameraToPixel,
|
|
float3 V,
|
|
float ScreenAmbientOcclusion,
|
|
float TopLayerSpecularContributionFactor,
|
|
FStrataIntegrationSettings Settings,
|
|
FStrataMaterialContainer MaterialBuffer,
|
|
FStrataAddressing StrataAddressing,
|
|
FStrataPixelHeader StrataPixelHeader,
|
|
float CloudVolumetricAOShadow,
|
|
inout float SSRReductionFactor,
|
|
inout float3 TopLayerEnvBRDF)
|
|
{
|
|
FStrataDeferredLighting StrataLighting = GetInitialisedStrataDeferredLighting();
|
|
|
|
SSRReductionFactor = 1.0f;
|
|
|
|
#if APPLY_SKY_SHADOWING
|
|
// Sample DFAO only once
|
|
FUpsampleDFAOOutput UpsampleDFAOOutput = UpsampleDFAO(BufferUV, SceneDepth);
|
|
#endif
|
|
|
|
float CombinedScreenAndMaterialAO = StrataGetAO(StrataPixelHeader) * ScreenAmbientOcclusion;
|
|
|
|
|
|
#if FEATURE_LEVEL >= FEATURE_LEVEL_SM5
|
|
float2 LocalPosition = SvPosition.xy - View.ViewRectMin.xy;
|
|
|
|
uint GridIndex = ComputeLightGridCellIndex(uint2(LocalPosition.x, LocalPosition.y), SceneDepth);
|
|
uint NumCulledEntryIndex = (ForwardLightData.NumGridCells + GridIndex) * NUM_CULLED_LIGHTS_GRID_STRIDE;
|
|
uint NumCulledReflectionCaptures = min(ForwardLightData.NumCulledLightsGrid[NumCulledEntryIndex + 0], ForwardLightData.NumReflectionCaptures);
|
|
uint CaptureDataStartIndex = ForwardLightData.NumCulledLightsGrid[NumCulledEntryIndex + 1];
|
|
#else
|
|
uint CaptureDataStartIndex = 0;
|
|
uint NumCulledReflectionCaptures = 0;
|
|
#endif
|
|
|
|
Strata_for (uint BSDFIndex = 0, BSDFIndex < StrataPixelHeader.BSDFCount, ++BSDFIndex)
|
|
{
|
|
FStrataBSDF BSDF = UnpackStrataBSDF(MaterialBuffer, StrataAddressing, StrataPixelHeader);
|
|
|
|
// Create the BSDF context
|
|
FStrataBSDFContext StrataBSDFContext = StrataCreateBSDFContext(StrataPixelHeader, BSDF, StrataAddressing, V);
|
|
|
|
const float3 BSDFThroughput = LuminanceWeight(StrataBSDFContext, BSDF); // Use the reflected direction
|
|
|
|
// Evaluate environment lighting
|
|
const bool bEnableSpecular = ReflectionStruct.SkyLightParameters.y > 0.0f;
|
|
FStrataEnvLightResult StrataEnvLight = StrataEvaluateForEnvLight(StrataBSDFContext, bEnableSpecular, Settings);
|
|
|
|
float3 BentNormal = StrataEnvLight.DiffuseNormal;
|
|
#if APPLY_SKY_SHADOWING
|
|
// Set DiffuseNormal as the bent normal for all diffuse computations.
|
|
BentNormal = ApplyDFAO(UpsampleDFAOOutput, StrataEnvLight.DiffuseNormal);
|
|
#endif
|
|
|
|
float3 DiffuseLighting = 0;
|
|
float3 SpecularLighting = 0;
|
|
StrataEnvLightingCommon(
|
|
StrataEnvLight,
|
|
StrataPixelHeader,
|
|
StrataBSDFContext,
|
|
BSDF,
|
|
BentNormal,
|
|
BSDFThroughput,
|
|
CaptureDataStartIndex,
|
|
NumCulledReflectionCaptures,
|
|
ScreenAmbientOcclusion,
|
|
CloudVolumetricAOShadow,
|
|
TopLayerSpecularContributionFactor,
|
|
TranslatedWorldPosition,
|
|
CombinedScreenAndMaterialAO,
|
|
SSRReductionFactor,
|
|
DiffuseLighting,
|
|
SpecularLighting);
|
|
|
|
const bool bIsTopLayer = BSDF_GETISTOPLAYER(BSDF);
|
|
if (bIsTopLayer)
|
|
{
|
|
// The specular path weight applied on SSR. It must account for throughput even for top surface because it also contains coverage.
|
|
TopLayerEnvBRDF += BSDFThroughput * StrataEnvLight.SpecularWeight;
|
|
}
|
|
|
|
// STRATA_TODO ReflectionEnvironment(...) for static reflection volumes.
|
|
|
|
FLightAccumulator Out = (FLightAccumulator)0;
|
|
LightAccumulator_AddSplit(Out, DiffuseLighting, SpecularLighting, DiffuseLighting, View.PreExposure, StrataEnvLight.bSubsurface);
|
|
AccumulateStrataDeferredLighting(StrataLighting, Out, StrataEnvLight.bSubsurface, BSDF_GETISTOPLAYER(BSDF));
|
|
}
|
|
|
|
SSRReductionFactor = saturate(SSRReductionFactor);
|
|
|
|
return StrataLighting;
|
|
}
|
|
|
|
#endif // STRATA_ENABLED |