Files
UnrealEngineUWP/Engine/Source/Runtime/Renderer/Private/TranslucentLighting.h
Arciel Rekman 3dd36a1d5f Share translucency light volume textures between both views of a stereo pair (UE-148569).
#rb Rob.Srinivasiah
#jira UE-148569
#preflight 627143035e6ce673f442a3dc
#review @Robert.Srinivasiah

[CL 20026126 by Arciel Rekman in ue5-main branch]
2022-05-03 11:15:00 -04:00

98 lines
3.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SceneRendering.h"
#include "RenderGraph.h"
struct FSortedLightSceneInfo;
struct FCloudShadowAOData;
class FLightSceneInfo;
class FProjectedShadowInfo;
struct FTranslucencyLightingVolumeTextures
{
/** Maps view to a texture index, accounting for sharing between some views */
int32 GetIndex(const FViewInfo& View, int32 CascadeIndex) const;
/** Initializes the translucent volume textures and clears them using a compute pass. PassFlags should be ERDGPassFlags::Compute or ERDGPassFlags::AsyncCompute. */
void Init(FRDGBuilder& GraphBuilder, TArrayView<const FViewInfo> Views, ERDGPassFlags PassFlags);
bool IsValid() const
{
check(!VolumeDim || (Ambient.Num() == Directional.Num() && Ambient.Num() > 0));
return VolumeDim != 0;
}
FRDGTextureRef GetAmbientTexture(const FViewInfo& View, int32 CascadeIndex) const
{
return Ambient[GetIndex(View, CascadeIndex)];
}
FRDGTextureRef GetDirectionalTexture(const FViewInfo& View, int32 CascadeIndex) const
{
return Directional[GetIndex(View, CascadeIndex)];
}
TArray<FRDGTextureRef, TInlineAllocator<TVC_MAX>> Ambient;
TArray<FRDGTextureRef, TInlineAllocator<TVC_MAX>> Directional;
int32 VolumeDim = 0;
/** Mapping between the view index and texture pair - needed because stereo views shares textures. */
TArray<int32, TInlineAllocator<2>> ViewsToTexturePairs;
};
BEGIN_SHADER_PARAMETER_STRUCT(FTranslucencyLightingVolumeParameters, )
SHADER_PARAMETER_RDG_TEXTURE(Texture3D, TranslucencyLightingVolumeAmbientInner)
SHADER_PARAMETER_RDG_TEXTURE(Texture3D, TranslucencyLightingVolumeAmbientOuter)
SHADER_PARAMETER_RDG_TEXTURE(Texture3D, TranslucencyLightingVolumeDirectionalInner)
SHADER_PARAMETER_RDG_TEXTURE(Texture3D, TranslucencyLightingVolumeDirectionalOuter)
END_SHADER_PARAMETER_STRUCT()
/** Initializes translucency volume lighting shader parameters from an optional textures struct. If null or uninitialized, fallback textures are used. */
FTranslucencyLightingVolumeParameters GetTranslucencyLightingVolumeParameters(FRDGBuilder& GraphBuilder, const FTranslucencyLightingVolumeTextures& Textures, const FViewInfo& View);
void InjectTranslucencyLightingVolume(
FRDGBuilder& GraphBuilder,
const FViewInfo& View,
const uint32 ViewIndex,
const FScene* Scene,
const FSceneRenderer& Renderer,
const FTranslucencyLightingVolumeTextures& Textures,
const TArrayView<const FVisibleLightInfo> VisibleLightInfos,
const FLightSceneInfo& LightSceneInfo,
const FProjectedShadowInfo* ProjectedShadowInfo);
void InjectTranslucencyLightingVolumeArray(
FRDGBuilder& GraphBuilder,
const TArrayView<const FViewInfo> Views,
const FScene* Scene,
const FSceneRenderer& Renderer,
const FTranslucencyLightingVolumeTextures& Textures,
const TArrayView<const FVisibleLightInfo> VisibleLightInfos,
const TArrayView<const FSortedLightSceneInfo> SortedLights,
const TInterval<int32> SortedLightInterval);
void InjectSimpleTranslucencyLightingVolumeArray(
FRDGBuilder& GraphBuilder,
const FViewInfo& View,
const uint32 ViewIndex,
const uint32 ViewCount,
const FTranslucencyLightingVolumeTextures& Textures,
const FSimpleLightArray& SimpleLights);
void FinalizeTranslucencyLightingVolume(
FRDGBuilder& GraphBuilder,
const TArrayView<const FViewInfo> Views,
FTranslucencyLightingVolumeTextures& Textures);
void InjectTranslucencyLightingVolumeAmbientCubemap(
FRDGBuilder& GraphBuilder,
const TArrayView<const FViewInfo> Views,
const FTranslucencyLightingVolumeTextures& Textures);
void FilterTranslucencyLightingVolume(
FRDGBuilder& GraphBuilder,
const TArrayView<const FViewInfo> Views,
FTranslucencyLightingVolumeTextures& Textures);