2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-06-11 18:27:07 -04:00
|
|
|
|
|
|
|
|
#include "SceneTextureParameters.h"
|
|
|
|
|
#include "SceneRendering.h"
|
2020-09-24 00:43:27 -04:00
|
|
|
#include "ScenePrivate.h"
|
2021-01-11 14:49:16 -04:00
|
|
|
#include "SceneTextures.h"
|
2019-06-11 18:27:07 -04:00
|
|
|
#include "SystemTextures.h"
|
|
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
FSceneTextureParameters GetSceneTextureParameters(FRDGBuilder& GraphBuilder)
|
2019-06-11 18:27:07 -04:00
|
|
|
{
|
2020-12-18 17:17:17 -04:00
|
|
|
return GetSceneTextureParameters(GraphBuilder, FSceneTextures::Get(GraphBuilder));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSceneTextureParameters GetSceneTextureParameters(FRDGBuilder& GraphBuilder, const FSceneTextures& SceneTextures)
|
|
|
|
|
{
|
2020-11-20 14:48:45 -04:00
|
|
|
const auto& SystemTextures = FRDGSystemTextures::Get(GraphBuilder);
|
2019-06-11 18:27:07 -04:00
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
FSceneTextureParameters Parameters;
|
2019-06-11 18:27:07 -04:00
|
|
|
|
|
|
|
|
// Should always have a depth buffer around allocated, since early z-pass is first.
|
2020-11-20 14:48:45 -04:00
|
|
|
Parameters.SceneDepthTexture = SceneTextures.Depth.Resolve;
|
2020-09-24 00:43:27 -04:00
|
|
|
Parameters.SceneStencilTexture = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::CreateWithPixelFormat(Parameters.SceneDepthTexture, PF_X24_G8));
|
2019-06-11 18:27:07 -04:00
|
|
|
|
|
|
|
|
// Registers all the scene texture from the scene context. No fallback is provided to catch mistake at shader parameter validation time
|
|
|
|
|
// when a pass is trying to access a resource before any other pass actually created it.
|
2020-11-20 14:48:45 -04:00
|
|
|
Parameters.GBufferVelocityTexture = GetIfProduced(SceneTextures.Velocity);
|
|
|
|
|
Parameters.GBufferATexture = GetIfProduced(SceneTextures.GBufferA);
|
|
|
|
|
Parameters.GBufferBTexture = GetIfProduced(SceneTextures.GBufferB);
|
|
|
|
|
Parameters.GBufferCTexture = GetIfProduced(SceneTextures.GBufferC);
|
|
|
|
|
Parameters.GBufferDTexture = GetIfProduced(SceneTextures.GBufferD);
|
|
|
|
|
Parameters.GBufferETexture = GetIfProduced(SceneTextures.GBufferE);
|
2020-12-08 08:33:21 -04:00
|
|
|
Parameters.GBufferFTexture = GetIfProduced(SceneTextures.GBufferF, SystemTextures.MidGrey);
|
2020-09-24 00:43:27 -04:00
|
|
|
|
|
|
|
|
return Parameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSceneTextureParameters GetSceneTextureParameters(FRDGBuilder& GraphBuilder, TRDGUniformBufferRef<FSceneTextureUniformParameters> SceneTextureUniformBuffer)
|
|
|
|
|
{
|
|
|
|
|
FSceneTextureParameters Parameters;
|
|
|
|
|
Parameters.SceneDepthTexture = (*SceneTextureUniformBuffer)->SceneDepthTexture;
|
|
|
|
|
if (Parameters.SceneDepthTexture)
|
|
|
|
|
{
|
|
|
|
|
Parameters.SceneStencilTexture = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::CreateWithPixelFormat(Parameters.SceneDepthTexture, PF_X24_G8));
|
|
|
|
|
}
|
|
|
|
|
Parameters.GBufferATexture = (*SceneTextureUniformBuffer)->GBufferATexture;
|
|
|
|
|
Parameters.GBufferBTexture = (*SceneTextureUniformBuffer)->GBufferBTexture;
|
|
|
|
|
Parameters.GBufferCTexture = (*SceneTextureUniformBuffer)->GBufferCTexture;
|
|
|
|
|
Parameters.GBufferDTexture = (*SceneTextureUniformBuffer)->GBufferDTexture;
|
|
|
|
|
Parameters.GBufferETexture = (*SceneTextureUniformBuffer)->GBufferETexture;
|
|
|
|
|
Parameters.GBufferFTexture = (*SceneTextureUniformBuffer)->GBufferFTexture;
|
|
|
|
|
Parameters.GBufferVelocityTexture = (*SceneTextureUniformBuffer)->GBufferVelocityTexture;
|
|
|
|
|
return Parameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSceneLightingChannelParameters GetSceneLightingChannelParameters(FRDGBuilder& GraphBuilder, FRDGTextureRef LightingChannelsTexture)
|
|
|
|
|
{
|
|
|
|
|
FSceneLightingChannelParameters Parameters;
|
2019-06-11 18:27:07 -04:00
|
|
|
|
2019-09-14 09:45:25 -04:00
|
|
|
// Lighting channels might be disabled when all lights are on the same channel.
|
2020-09-24 00:43:27 -04:00
|
|
|
if (LightingChannelsTexture)
|
2019-06-11 18:27:07 -04:00
|
|
|
{
|
2020-09-24 00:43:27 -04:00
|
|
|
Parameters.SceneLightingChannels = LightingChannelsTexture;
|
|
|
|
|
Parameters.bSceneLightingChannelsValid = true;
|
2019-06-11 18:27:07 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-09-24 00:43:27 -04:00
|
|
|
Parameters.SceneLightingChannels = GraphBuilder.RegisterExternalTexture(GSystemTextures.WhiteDummy);
|
|
|
|
|
Parameters.bSceneLightingChannelsValid = false;
|
2019-06-11 18:27:07 -04:00
|
|
|
}
|
2020-09-24 00:43:27 -04:00
|
|
|
|
|
|
|
|
return Parameters;
|
2019-06-11 18:27:07 -04:00
|
|
|
}
|
|
|
|
|
|
2020-09-24 00:43:27 -04:00
|
|
|
FRDGTextureRef GetEyeAdaptationTexture(FRDGBuilder& GraphBuilder, const FSceneView& View)
|
2019-06-11 18:27:07 -04:00
|
|
|
{
|
2020-09-24 00:43:27 -04:00
|
|
|
if (View.HasValidEyeAdaptationTexture())
|
2019-06-11 18:27:07 -04:00
|
|
|
{
|
2020-09-24 00:43:27 -04:00
|
|
|
return GraphBuilder.RegisterExternalTexture(View.GetEyeAdaptationTexture(), ERenderTargetTexture::Targetable, ERDGTextureFlags::MultiFrame);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return GraphBuilder.RegisterExternalTexture(GSystemTextures.WhiteDummy);
|
2019-06-11 18:27:07 -04:00
|
|
|
}
|
|
|
|
|
}
|
2020-09-24 00:43:27 -04:00
|
|
|
|
2021-02-02 04:25:26 -04:00
|
|
|
FRDGBufferRef GetEyeAdaptationBuffer(FRDGBuilder& GraphBuilder, const FSceneView& View)
|
2020-09-24 00:43:27 -04:00
|
|
|
{
|
|
|
|
|
if (View.HasValidEyeAdaptationBuffer())
|
|
|
|
|
{
|
2021-02-02 04:25:26 -04:00
|
|
|
return GraphBuilder.RegisterExternalBuffer(View.GetEyeAdaptationBuffer(), ERDGBufferFlags::MultiFrame);
|
2020-09-24 00:43:27 -04:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-02-02 04:25:26 -04:00
|
|
|
return GraphBuilder.RegisterExternalBuffer(GWhiteVertexBufferWithRDG->Buffer);
|
2020-09-24 00:43:27 -04:00
|
|
|
}
|
|
|
|
|
}
|